[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v9 1/6] luks2: Convert to crypt sectors from grub native sectors
From: |
Glenn Washburn |
Subject: |
[PATCH v9 1/6] luks2: Convert to crypt sectors from grub native sectors |
Date: |
Tue, 15 Dec 2020 17:31:06 -0600 |
The function grub_disk_native_sectors(source) returns the number of sectors
of source in grub native (512-byte) sectors, not source sized sectors. So
the conversion needs to use GRUB_DISK_SECTOR_BITS. the grub native sector
size.
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
grub-core/disk/luks2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c
index 8d2457557..8c1156dd0 100644
--- a/grub-core/disk/luks2.c
+++ b/grub-core/disk/luks2.c
@@ -631,7 +631,7 @@ luks2_recover_key (grub_disk_t source,
crypt->log_sector_size = sizeof (unsigned int) * 8
- __builtin_clz ((unsigned int) segment.sector_size) - 1;
if (grub_strcmp (segment.size, "dynamic") == 0)
- crypt->total_sectors = (grub_disk_native_sectors (source) >>
(crypt->log_sector_size - source->log_sector_size))
+ crypt->total_sectors = (grub_disk_native_sectors (source) >>
(crypt->log_sector_size - GRUB_DISK_SECTOR_BITS))
- crypt->offset_sectors;
else
crypt->total_sectors = grub_strtoull (segment.size, NULL, 10) >>
crypt->log_sector_size;
--
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 <=
- [PATCH v9 2/6] luks2: Do not handle disks of size GRUB_DISK_SIZE_UNKNOWN for now, Glenn Washburn, 2020/12/15
- [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