Skip to contentSkip to conversation

Behaviour if GRUB_ENABLE_CRYPTODISK is unset?

PATCH Colin Watson 4 participants 8 messages Dec 7, 2013 – Dec 10, 2013

lore
Share & tools
lore
#0 lore raw

I'm carrying this old patch in Debian at the moment, which predates the addition of LUKS support to GRUB:

util/grub-mkconfig_lib.in +9 -0
Index: b/util/grub-mkconfig_lib.in
===================================================================
@@ -130,6 +130,15 @@
     esac
   done
 
+  if dmsetup status $device 2>/dev/null | grep -q 'crypt[[:space:]]$'; then
+    grub_warn \
+      "$device is a crypto device, which GRUB cannot read directly.  Some" \
+      "necessary modules may be missing from /boot/grub/grub.cfg.  You may" \
+      "need to list them in GRUB_PRELOAD_MODULES in /etc/default/grub.  See" \
+      "http://bugs.debian.org/542165 for details."
+    return 0
+  fi
+
   # Abstraction modules aren't auto-loaded.
   abstraction="`"${grub_probe}" --device $@ --target=abstraction`"
   for module in ${abstraction} ; do

Now, this is obviously wrong because it renders LUKS support mostly non-functional even if you have GRUB_ENABLE_CRYPTODISK=y, so I'd like to drop it, but that does mean that people who *don't* have GRUB_ENABLE_CRYPTODISK=y will once again see no hint of what to do.

I've never totally understood why GRUB_ENABLE_CRYPTODISK is optional to begin with; it seems like a bit of a "do you want things to work? [y/N]" option to me. My preferred approach would be to delete the option. If there's some reason we can't do that, perhaps it would be worth checking for whether it would have any effect if enabled, and if so print an explanatory warning?

Thanks,

Signature · 1 line
Colin Watson                                       [[email protected]]
#1 lore raw
Quoted 3 lines · Colin Watson

I've never totally understood why GRUB_ENABLE_CRYPTODISK is optional to begin with; it seems like a bit of a "do you want things to work? [y/N]" option to me. My preferred approach would be to delete the option.

Cryptodisk support is allowed to ask user for password which is not possible for unattended systems.
E.g. in old config GRUB was looking for unifont under /usr/share. If you make cryptodisk default a server doing this would stop in password prompt rather than skipping unifont and going to text mode and continuing booting.

#7 lore raw
In reply to Colin Watson

В Sat, 7 Dec 2013 13:27:26 +0000
Colin Watson <[email protected]> пишет:

Quoted 29 lines

I'm carrying this old patch in Debian at the moment, which predates the addition of LUKS support to GRUB:

Index: b/util/grub-mkconfig_lib.in
===================================================================

util/grub-mkconfig_lib.in +9 -0
@@ -130,6 +130,15 @@
     esac
   done
 
+  if dmsetup status $device 2>/dev/null | grep -q 'crypt[[:space:]]$'; then
+    grub_warn \
+      "$device is a crypto device, which GRUB cannot read directly.  Some" \
+      "necessary modules may be missing from /boot/grub/grub.cfg.  You may" \
+      "need to list them in GRUB_PRELOAD_MODULES in /etc/default/grub.  See" \
+      "http://bugs.debian.org/542165 for details."
+    return 0
+  fi
+
   # Abstraction modules aren't auto-loaded.
   abstraction="`"${grub_probe}" --device $@ --target=abstraction`"
   for module in ${abstraction} ; do

Now, this is obviously wrong because it renders LUKS support mostly non-functional even if you have GRUB_ENABLE_CRYPTODISK=y, so I'd like to drop it, but that does mean that people who *don't* have GRUB_ENABLE_CRYPTODISK=y will once again see no hint of what to do.

Quoted 7 lines

I've never totally understood why GRUB_ENABLE_CRYPTODISK is optional to begin with; it seems like a bit of a "do you want things to work? [y/N]" option to me. My preferred approach would be to delete the option. If there's some reason we can't do that, perhaps it would be worth checking for whether it would have any effect if enabled, and if so print an explanatory warning?

I think it came up recently and explanation was, in this case grub may unintentionally end up to need more crypto devices than user expects and thus waiting for passphrase on boot.

One reason it may happen is due to font handling. First, undocumented GRUB_FONT which can theoretically point anywhere; second fallback to /usr/share and similar if GRUB_FONT is not defined. So even if /boot itself is unencrypted, you may suddenly pull in encrypted root.

#2 lore raw
In reply to Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 11 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 3 lines · Colin Watson

I've never totally understood why GRUB_ENABLE_CRYPTODISK is optional to begin with; it seems like a bit of a "do you want things to work? [y/N]" option to me. My preferred approach would be to delete the option.

Cryptodisk support is allowed to ask user for password which is not possible for unattended systems.
E.g. in old config GRUB was looking for unifont under /usr/share. If you make cryptodisk default a server doing this would stop in password prompt rather than skipping unifont and going to text mode and continuing booting.

OK. I get that we don't necessarily want to be noisy if it's just for something optional. But if somebody's /boot is on LUKS, it would be nice to tell them how to enable support for that rather than just having grub-mkconfig fail, right? I think grub-install already gives specific instructions, so we could do that in grub-mkconfig too.

Signature · 1 line
Colin Watson                                       [[email protected]]
#3 lore raw
Quoted 13 lines · Colin Watson
Quoted 11 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 3 lines · Colin Watson

I've never totally understood why GRUB_ENABLE_CRYPTODISK is optional to begin with; it seems like a bit of a "do you want things to work? [y/N]" option to me. My preferred approach would be to delete the option.

Cryptodisk support is allowed to ask user for password which is not possible for unattended systems.
E.g. in old config GRUB was looking for unifont under /usr/share. If you make cryptodisk default a server doing this would stop in password prompt rather than skipping unifont and going to text mode and continuing booting.

Quoted 5 lines

OK. I get that we don't necessarily want to be noisy if it's just for something optional. But if somebody's /boot is on LUKS, it would be nice to tell them how to enable support for that rather than just having grub-mkconfig fail, right? I think grub-install already gives specific instructions, so we could do that in grub-mkconfig too.

Encrypted /boot seems to be an edge case, at least for x86 UEFI, on which increasingly systems are shipping with a firmware that doesn't initialize USB at all in order shave off boot time. For these systems, as far as I know, GRUB, or any boot manager, can't initialize USB while boot services is still active. So we're looking at systems with no interactive means to manipulate a boot menu at boot time, or type in passwords. Instead it seems we need an application that modifies e.g. grubenv so the grub.cfg knows what to boot.

Anyway, I'm uncertain about the benefit of encrypted /boot. If boot files are supposed to be protected from modification then that's what secure boot is for.

Chris Murphy

#4 lore raw
Quoted 22 lines · Chris Murphy
Quoted 13 lines · Colin Watson
Quoted 11 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 3 lines · Colin Watson

I've never totally understood why GRUB_ENABLE_CRYPTODISK is optional to begin with; it seems like a bit of a "do you want things to work? [y/N]" option to me. My preferred approach would be to delete the option.

Cryptodisk support is allowed to ask user for password which is not possible for unattended systems.
E.g. in old config GRUB was looking for unifont under /usr/share. If you make cryptodisk default a server doing this would stop in password prompt rather than skipping unifont and going to text mode and continuing booting.

Quoted 5 lines

OK. I get that we don't necessarily want to be noisy if it's just for something optional. But if somebody's /boot is on LUKS, it would be nice to tell them how to enable support for that rather than just having grub-mkconfig fail, right? I think grub-install already gives specific instructions, so we could do that in grub-mkconfig too.

Quoted 5 lines

Encrypted /boot seems to be an edge case, at least for x86 UEFI, on which increasingly systems are shipping with a firmware that doesn't initialize USB at all in order shave off boot time. For these systems, as far as I know, GRUB, or any boot manager, can't initialize USB while boot services is still active. So we're looking at systems with no interactive means to manipulate a boot menu at boot time, or type in passwords. Instead it seems we need an application that modifies e.g. grubenv so the grub.cfg knows what to boot.

Anyway, I'm uncertain about the benefit of encrypted /boot. If boot files are supposed to be protected from modification then that's what secure boot is for.

That's all beside the original topic of this thread. This is unfortunate that this becomes a tendency on this list to usurp threads for unrelated comments.
And note that encrypted /boot as part of encrypted / is easier to manage in some cases

Quoted 6 lines

Chris Murphy
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#5 lore raw
In reply to Chris Murphy
Quoted 1 line · Chris Murphy

Encrypted /boot seems to be an edge case, at least for x86 UEFI

[...]

GRUB supports many platforms; an issue with a single one, even if it's common, doesn't in general mean we shouldn't take straightforward measures to improve things for others.

Signature · 1 line
Colin Watson                                       [[email protected]]
#6 lore raw
Quoted 7 lines · Colin Watson
Quoted 1 line · Chris Murphy

Encrypted /boot seems to be an edge case, at least for x86 UEFI

[...]

GRUB supports many platforms; an issue with a single one, even if it's common, doesn't in general mean we shouldn't take straightforward measures to improve things for others.

Fair enough.

Chris Murphy