Re: [PATCH v4 13/15] cryptodisk: Properly handle non-512 byte sized sectors.

2020-11-22 Thread Patrick Steinhardt
On Fri, Nov 20, 2020 at 02:42:35AM -0600, Glenn Washburn wrote: > On Sun, 15 Nov 2020 11:07:27 +0100 > Patrick Steinhardt wrote: > > > On Fri, Nov 06, 2020 at 10:44:33PM -0600, Glenn Washburn wrote: > > > By default, dm-crypt internally uses an IV that corresponds to > > > 512-byte sectors, even

[PATCH v5 00/11] Cryptodisk fixes for v2.06 redux

2020-11-22 Thread Glenn Washburn
This incorporates changes as noted in the v4 thread. This series has been rebased on the new master from accepted patches from v4. This means that patch 8 from v4 would be patch 1 in this series. However, I reworked 8-10 from v4 from 3 patches into 2, and I believe simplified the changeset. So v4

[PATCH v5 03/11] cryptodisk: Replace some literals with constants in grub_cryptodisk_endecrypt

2020-11-22 Thread Glenn Washburn
This should improve readability of code by providing clues as to what the value represents. The new macro GRUB_TYPE_BITS(type) returns the number of bits allocated for type. Also add GRUB_TYPE_U_MAX/MIN(type) macros to get the max/min values for an unsigned number with size of type. Signed-off-by:

[PATCH v5 06/11] luks2: Better error handling when setting up the cryptodisk

2020-11-22 Thread Glenn Washburn
First, 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

[PATCH v5 09/11] mips: Enable __clzdi2()

2020-11-22 Thread Glenn Washburn
This patch is similiar to commit 9dab2f51e (sparc: Enable __clzsi2() and __clzdi2()) but for MIPS target and __clzdi2 only, __clzsi2 was already enabled. Signed-off-by: Daniel Kiper --- grub-core/kern/compiler-rt.c | 2 +- include/grub/compiler-rt.h | 2 +- 2 files changed, 2 insertions(+), 2

[PATCH v5 01/11] luks2: Add slot_key member to struct grub_luks2_keyslot/segment/digest

2020-11-22 Thread Glenn Washburn
This allows code using these structs to know the named key associated with these json data structures. In the future we can use these to provide better error messages to the user. Get rid of idx variable in luks2_get_keyslot which was overloaded to be used for both keyslot and segment slot keys.

[PATCH v5 07/11] luks2: Error check segment.sector_size

2020-11-22 Thread Glenn Washburn
Signed-off-by: Glenn Washburn --- 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 2f2515fb6..0d838f2e0 100644 --- a/grub-core/disk/luks2.c +++ b/grub-core/disk/luks2.c @@ -626,6 +626,17 @@ luks2_recover_

[PATCH v5 02/11] luks: Use more intuitive slot key instead of index in user messages.

2020-11-22 Thread Glenn Washburn
Use the slot key name in the json array rather than the 0 based index in the json array for keyslots, segments, and digests. This is less confusing for the end user. For example, say you have a LUKS2 device with a key in slot 1 and slot 4. When using the password for slot 4 to unlock the device, th

[PATCH v5 10/11] misc: Add grub_log2ull macro for calculating log base 2 of 64-bit integers

2020-11-22 Thread Glenn Washburn
Signed-off-by: Glenn Washburn --- include/grub/misc.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/grub/misc.h b/include/grub/misc.h index b7ca6dd58..85a481f0c 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -482,4 +482,7 @@ void EXPORT_FUNC(grub_real_boot_time) (c

[PATCH v5 04/11] luks2: grub_cryptodisk_t->total_sectors is the max number of device native sectors

2020-11-22 Thread Glenn Washburn
We need to convert the sectors from the size of the underlying device to the cryptodisk sector size; segment.size is in bytes which need to be converted to cryptodisk sectors as well. And counter-intuitively, grub_disk_get_size returns the total number of device native sectors. Also, removed an em

[PATCH v5 05/11] cryptodisk: Properly handle non-512 byte sized sectors

2020-11-22 Thread Glenn Washburn
By default, dm-crypt internally uses an IV that corresponds to 512-byte sectors, even when a larger sector size is specified. What this means is that when using a larger sector size, the IV is incremented every sector. However, the amount the IV is incremented is the number of 512 byte blocks in a

[PATCH v5 08/11] whitespace: convert 8 spaces to tabs.

2020-11-22 Thread Glenn Washburn
Signed-off-by: Glenn Washburn --- grub-core/disk/luks2.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c index 0d838f2e0..7e7b79d17 100644 --- a/grub-core/disk/luks2.c +++ b/grub-core/disk/luks2.c @@ -279,8 +279,8 @@ luks

[PATCH v5 11/11] luks2: Use grub_log2ull to calculate log_sector_size and improve readability

2020-11-22 Thread Glenn Washburn
Signed-off-by: Glenn Washburn --- grub-core/disk/luks2.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c index 7e7b79d17..de3933be8 100644 --- a/grub-core/disk/luks2.c +++ b/grub-core/disk/luks2.c @@ -639,8 +639,7 @@ luks2_reco