All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] builddeb: Support signing kernels with the module signing key
@ 2021-12-18  3:11 Matthew Wilcox (Oracle)
  2022-01-04 15:39 ` Masahiro Yamada
  0 siblings, 1 reply; 15+ messages in thread
From: Matthew Wilcox (Oracle) @ 2021-12-18  3:11 UTC (permalink / raw)
  To: linux-kbuild
  Cc: Matthew Wilcox (Oracle),
	linux-kernel, efi, debian-kernel, linux-efi, Ard Biesheuvel,
	Masahiro Yamada

If the config file specifies a signing key, use it to sign
the kernel so that machines with SecureBoot enabled can boot.
See https://wiki.debian.org/SecureBoot

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
v2:
 - Handle private keys stored in the pem file as well as adjacent to the
   certificate
 - Handle certificate paths specified relative to both dsttree and srctree
   (as well as absolute)
 - Only try to sign the executable if EFI_STUB is enabled
 - Only try to execute sbsign if it's in $PATH

 scripts/package/builddeb | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 91a502bb97e8..9dd92fd02b12 100755
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -147,7 +147,30 @@ else
 	cp System.map "$tmpdir/boot/System.map-$version"
 	cp $KCONFIG_CONFIG "$tmpdir/boot/config-$version"
 fi
-cp "$($MAKE -s -f $srctree/Makefile image_name)" "$tmpdir/$installed_image_path"
+
+vmlinux=$($MAKE -s -f $srctree/Makefile image_name)
+key=
+if is_enabled CONFIG_EFI_STUB && is_enabled CONFIG_MODULE_SIG; then
+	cert=$(grep ^CONFIG_MODULE_SIG_KEY= include/config/auto.conf | cut -d\" -f2)
+	if [ ! -f $cert ]; then
+		cert=$srctree/$cert
+	fi
+
+	key=${cert%pem}priv
+	if [ ! -f $key ]; then
+		key=$cert
+	fi
+
+	if ! command -v sbsign >/dev/null; then
+		key=
+	fi
+fi
+
+if [ -n "$key" ]; then
+	sbsign --key $key --cert $cert "$vmlinux" --output "$tmpdir/$installed_image_path"
+else
+	cp "$vmlinux" "$tmpdir/$installed_image_path"
+fi
 
 if is_enabled CONFIG_OF_EARLY_FLATTREE; then
 	# Only some architectures with OF support have this target
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2022-02-10  4:38 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-18  3:11 [PATCH v2] builddeb: Support signing kernels with the module signing key Matthew Wilcox (Oracle)
2022-01-04 15:39 ` Masahiro Yamada
2022-01-04 18:13   ` Matthew Wilcox
2022-02-07 12:33     ` Masahiro Yamada
2022-02-07 13:30       ` Matthew Wilcox
2022-02-08  4:09         ` Masahiro Yamada
2022-02-08 11:01       ` Julian Andres Klode
2022-02-08 13:10         ` Matthew Wilcox
2022-02-08 16:12           ` Julian Andres Klode
2022-02-09 23:03             ` Masahiro Yamada
2022-02-09 13:21           ` James Bottomley
2022-02-09 23:04             ` Masahiro Yamada
2022-02-04 22:30   ` Matthew Wilcox
2022-02-07 13:22     ` Masahiro Yamada
2022-02-09 23:05       ` Ben Hutchings

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.