lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20241015222235.71040-6-jeremy.linton@arm.com>
Date: Tue, 15 Oct 2024 17:22:35 -0500
From: Jeremy Linton <jeremy.linton@....com>
To: linux-kernel@...r.kernel.org
Cc: akpm@...ux-foundation.org,
	hch@....de,
	gregkh@...uxfoundation.org,
	graf@...zon.com,
	lukas@...ner.de,
	wufan@...ux.microsoft.com,
	brauner@...nel.org,
	jsperbeck@...gle.com,
	ardb@...nel.org,
	linux-crypto@...r.kernel.org,
	linux-kbuild@...r.kernel.org,
	keyrings@...r.kernel.org,
	Jeremy Linton <jeremy.linton@....com>
Subject: [RFC 5/5] initramfs: Enforce initramfs signature

Now that the infrastructure is in place to verify and sign initramfs
images, let's refuse them if the signature is invalid. Additionally, a
command-line option `initrdsig=[enforcing|checking]` is provided to
switch between failing to boot or reporting signature failures.

Signed-off-by: Jeremy Linton <jeremy.linton@....com>
---
 init/initramfs.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/init/initramfs.c b/init/initramfs.c
index d2d2c68016c2..bb42ba6c0730 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -573,6 +573,20 @@ static int __init initramfs_async_setup(char *str)
 }
 __setup("initramfs_async=", initramfs_async_setup);
 
+static bool  __initdata enforce_initrd_sig = IS_ENABLED(CONFIG_INITRAMFS_SIG);
+#ifdef CONFIG_INITRAMFS_SIG
+static int __init initrd_sig_setup(char *str)
+{
+	if (!strcmp(str, "enforcing"))
+		enforce_initrd_sig = true;
+	else if (!strcmp(str, "checking"))
+		enforce_initrd_sig = false;
+	return 1;
+}
+__setup("initrdsig=", initrd_sig_setup);
+#endif
+
+
 extern char __initramfs_start[];
 extern unsigned long __initramfs_size;
 #include <linux/initrd.h>
@@ -766,7 +780,10 @@ static void __init do_populate_rootfs(void *unused, async_cookie_t cookie)
 	else
 		printk(KERN_INFO "Unpacking initramfs...\n");
 
-	initrd_signature_check(&initrd_len);
+	if (initrd_signature_check(&initrd_len) && enforce_initrd_sig) {
+		printk(KERN_EMERG "Initramfs signature required\n");
+		goto done;
+	}
 
 	err = unpack_to_rootfs((char *)initrd_start, initrd_len);
 	if (err) {
-- 
2.46.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ