[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/4] luks2: set up dummy sector size during scan

From: Patrick Steinhardt
Subject: [PATCH 3/4] luks2: set up dummy sector size during scan
Date: Sat, 30 May 2020 14:25:17 +0200

GRUB currently only supports disk sector sizes of at least 9 bits. While
not a problem when using decrypted LUKS2 disks, where we configure the
sector size after we have decrypted the disk, it will cause failure as
soon as we implement support for probing of LUKS2 encrypted disks: we
only cheat-mount devices there and don't perform a real decryption, and
thus the sector size will remain "0", causing errors at a later point.

The problem here is that we can only determine the sector size as soon
as we have decrypted a key slot, as key slots may refer to different
segments, where each segment in turn may have a different sector size.
As we don't really need the sector size during cheat-mounting anyway,
let's just specify the minimum value as dummy to fix such errors.

This patch is in preparation for probing support.

Signed-off-by: Patrick Steinhardt <>
 grub-core/disk/luks2.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c
index c847b4ac4..5c00d9775 100644
--- a/grub-core/disk/luks2.c
+++ b/grub-core/disk/luks2.c
@@ -374,6 +374,14 @@ luks2_scan (grub_disk_t disk, const char *check_uuid, int 
   grub_memcpy (cryptodisk->uuid, uuid, sizeof (uuid));
   cryptodisk->modname = "luks2";
+  /*
+   * This dummy value is required when cheat-mounting and is overridden by
+   * `luks2_verify_key ()`. We can't determine it here yet, as its value
+   * depends on which disk sector we're going to open, which in turn depends on
+   * the keyslot.
+   */
+  cryptodisk->log_sector_size = GRUB_DISK_SECTOR_BITS;
   return cryptodisk;

Attachment: signature.asc
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]