[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v9 2/6] luks2: Do not handle disks of size GRUB_DISK_SIZE_UNKNOWN
From: |
Glenn Washburn |
Subject: |
[PATCH v9 2/6] luks2: Do not handle disks of size GRUB_DISK_SIZE_UNKNOWN for now |
Date: |
Tue, 15 Dec 2020 17:31:07 -0600 |
Check to make sure that source disk has a known size. If not, print debug
message and return error. There are 4 cases where GRUB_DISK_SIZE_UNKNOWN is
set (biosdisk, obdisk, ofdisk, and uboot), and in all those cases processing
continues. So this is probably a bit conservative. However, 3 of the cases
seem pathological, and the other, biosdisk, happens when booting from a cd.
Since I doubt booting from a LUKS2 volume on a cd is a big use case, we'll
error until someone complains.
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
grub-core/disk/luks2.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c
index 8c1156dd0..d30c3bfff 100644
--- a/grub-core/disk/luks2.c
+++ b/grub-core/disk/luks2.c
@@ -600,6 +600,15 @@ luks2_recover_key (grub_disk_t source,
goto err;
}
+ if (grub_disk_native_sectors(source) == GRUB_DISK_SIZE_UNKNOWN)
+ {
+ /* FIXME: Allow use of source disk, and maybe cause errors in read. */
+ grub_dprintf ("luks2", "Source disk %s has an unknown size, "
+ "conservatively returning error\n", source->name);
+ ret = grub_error (GRUB_ERR_BUG, "Unknown size of luks2 source device");
+ goto err;
+ }
+
/* Try all keyslot */
for (json_idx = 0; json_idx < size; json_idx++)
{
--
2.27.0
- [PATCH v9 0/6] Cryptodisk fixes for v2.06 redux, Glenn Washburn, 2020/12/15
- [PATCH v9 1/6] luks2: Convert to crypt sectors from grub native sectors, Glenn Washburn, 2020/12/15
- [PATCH v9 2/6] luks2: Do not handle disks of size GRUB_DISK_SIZE_UNKNOWN for now,
Glenn Washburn <=
- [PATCH v9 3/6] luks2: Better error handling when setting up the cryptodisk, Glenn Washburn, 2020/12/15
- [PATCH v9 4/6] mips: Enable __clzdi2(), Glenn Washburn, 2020/12/15
- [PATCH v9 5/6] misc: Add grub_log2ull macro for calculating log base 2 of 64-bit integers, Glenn Washburn, 2020/12/15
- [PATCH v9 6/6] luks2: Use grub_log2ull to calculate log_sector_size and improve readability, Glenn Washburn, 2020/12/15