[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v8 15/18] luks2: Error check segment.sector_size
From: |
Glenn Washburn |
Subject: |
[PATCH v8 15/18] luks2: Error check segment.sector_size |
Date: |
Tue, 8 Dec 2020 16:45:46 -0600 |
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 8cb11e899..c737797b9 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.idx);
+ /* 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.idx, 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
- Re: [PATCH v8 09/18] luks2: Add string "index" to user strings using a json index., (continued)
- [PATCH v8 10/18] cryptodisk: Add macro GRUB_TYPE_BITS() to replace some literals, Glenn Washburn, 2020/12/08
- [PATCH v8 14/18] luks2: Better error handling when setting up the cryptodisk, Glenn Washburn, 2020/12/08
- [PATCH v8 15/18] luks2: Error check segment.sector_size,
Glenn Washburn <=
- [PATCH v8 16/18] mips: Enable __clzdi2(), Glenn Washburn, 2020/12/08
- [PATCH v8 18/18] luks2: Use grub_log2ull to calculate log_sector_size and improve readability, Glenn Washburn, 2020/12/08
- Re: [PATCH v8 00/18] Cryptodisk fixes for v2.06 redux, Daniel Kiper, 2020/12/10