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-next>] [day] [month] [year] [list]
Date:   Thu,  7 Apr 2022 05:40:14 +0300
From:   Baskov Evgeniy <baskov@...ras.ru>
To:     Thomas Gleixner <tglx@...utronix.de>
Cc:     Baskov Evgeniy <baskov@...ras.ru>, Ingo Molnar <mingo@...hat.com>,
        Borislav Petkov <bp@...en8.de>,
        Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH] x86: Parse CONFIG_CMDLINE in compressed kernel

CONFIG_CMDLINE_BOOL and CONFIG_CMDLINE_OVERRIDE was ignored
during options lookup in compressed kernel, including
earlyprintk option, so it was impossible to get earlyprintk
messages from that stage of boot process via command line
provided at compile time. Being able to enable earlyprintk
via compile-time option might be desirable for booting
on systems with broken UEFI command line arguments via EFISTUB.

Parse CONFIG_CMDLINE-related options correctly in compressed
kernel code.

Signed-off-by: Baskov Evgeniy <baskov@...ras.ru>

diff --git a/arch/x86/boot/compressed/cmdline.c b/arch/x86/boot/compressed/cmdline.c
index f1add5d85da9..dd8cbbe61dff 100644
--- a/arch/x86/boot/compressed/cmdline.c
+++ b/arch/x86/boot/compressed/cmdline.c
@@ -22,9 +22,49 @@ unsigned long get_cmd_line_ptr(void)
 }
 int cmdline_find_option(const char *option, char *buffer, int bufsize)
 {
-	return __cmdline_find_option(get_cmd_line_ptr(), option, buffer, bufsize);
+	int len = -1;
+	unsigned long cmdline_ptr;
+
+	/*
+	 * First try command line string provided by user,
+	 * then try command line string configured at comple time.
+	 * Skip first step if CONFIG_CMDLINE_OVERRIDE is enabled
+	 * and parse only compile time command line.
+	 */
+
+	if (!IS_ENABLED(CONFIG_CMDLINE_OVERRIDE)) {
+		cmdline_ptr = get_cmd_line_ptr();
+		len = __cmdline_find_option(cmdline_ptr, option,
+					    buffer, bufsize);
+	}
+
+#ifdef CONFIG_CMDLINE_BOOL
+	if (len < 0) {
+		cmdline_ptr = (unsigned long)CONFIG_CMDLINE;
+		len = __cmdline_find_option(cmdline_ptr, option,
+					    buffer, bufsize);
+	}
+#endif
+
+	return len;
 }
 int cmdline_find_option_bool(const char *option)
 {
-	return __cmdline_find_option_bool(get_cmd_line_ptr(), option);
+	int len = -1;
+	unsigned long cmdline_ptr;
+
+	if (!IS_ENABLED(CONFIG_CMDLINE_OVERRIDE)) {
+		cmdline_ptr = get_cmd_line_ptr();
+		len = __cmdline_find_option_bool(cmdline_ptr, option);
+	}
+
+
+#ifdef CONFIG_CMDLINE_BOOL
+	if (len < 0) {
+		cmdline_ptr = (unsigned long)CONFIG_CMDLINE;
+		len = __cmdline_find_option_bool(cmdline_ptr, option);
+	}
+#endif
+
+	return len;
 }
-- 
2.35.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ