[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 13/17] luks2: Error check segment.sector_size
From: |
Glenn Washburn |
Subject: |
[PATCH v7 13/17] luks2: Error check segment.sector_size |
Date: |
Fri, 4 Dec 2020 10:43:42 -0600 |
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
grub-core/disk/luks2.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c
index 1bb3a333d..499c9330b 100644
--- a/grub-core/disk/luks2.c
+++ b/grub-core/disk/luks2.c
@@ -629,6 +629,17 @@ luks2_recover_key (grub_disk_t source,
grub_dprintf ("luks2", "Trying keyslot \"%"PRIuGRUB_UINT64_T"\"\n",
keyslot.json_slot_key);
+ /* Sector size should be one of 512, 1024, 2048, or 4096. */
+ if (!(segment.sector_size == 512 || segment.sector_size == 1024 ||
+ segment.sector_size == 2048 || segment.sector_size == 4096))
+ {
+ grub_dprintf ("luks2", "Segment \"%"PRIuGRUB_UINT64_T"\" sector"
+ " size %"PRIuGRUB_UINT64_T" is not one of"
+ " 512, 1024, 2048, or 4096\n",
+ segment.json_slot_key, segment.sector_size);
+ continue;
+ }
+
/* Set up disk according to keyslot's segment. */
crypt->offset_sectors = grub_divmod64 (segment.offset,
segment.sector_size, NULL);
crypt->log_sector_size = sizeof (unsigned int) * 8
--
2.27.0
- [PATCH v7 07/17] luks2: Add string "index" to user strings using a json index., (continued)
- [PATCH v7 07/17] luks2: Add string "index" to user strings using a json index., Glenn Washburn, 2020/12/04
- [PATCH v7 10/17] luks2: grub_cryptodisk_t->total_sectors is the max number of device native sectors, Glenn Washburn, 2020/12/04
- [PATCH v7 01/17] disk: Rename grub_disk_get_size to grub_disk_native_sectors, Glenn Washburn, 2020/12/04
- [PATCH v7 16/17] misc: Add grub_log2ull macro for calculating log base 2 of 64-bit integers, Glenn Washburn, 2020/12/04
- [PATCH v7 13/17] luks2: Error check segment.sector_size,
Glenn Washburn <=
- [PATCH v7 08/17] cryptodisk: Add macro GRUB_TYPE_BITS() to replace some literals, Glenn Washburn, 2020/12/04
- [PATCH v7 06/17] luks2: Use more intuitive slot key instead of index in user messages, Glenn Washburn, 2020/12/04
- [PATCH v7 03/17] luks2: Remove unused argument in grub_error, Glenn Washburn, 2020/12/04