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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu,  5 May 2022 13:32:24 +0300
From:   Baskov Evgeniy <baskov@...ras.ru>
To:     Borislav Petkov <bp@...en8.de>
Cc:     Baskov Evgeniy <baskov@...ras.ru>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>,
        Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH v3 2/2] x86: Parse CONFIG_CMDLINE in compressed kernel

CONFIG_CMDLINE, CONFIG_CMDLINE_BOOL, and CONFIG_CMDLINE_OVERRIDE were
ignored during options lookup in compressed kernel.

Parse CONFIG_CMDLINE-related options correctly in compressed kernel
code.

cmd_line_ptr_init is explicitly placed in .data section since it is
used and expected to be equal to zero before .bss section is cleared.

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..261f53ad395a 100644
--- a/arch/x86/boot/compressed/cmdline.c
+++ b/arch/x86/boot/compressed/cmdline.c
@@ -1,6 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "misc.h"
 
+#define COMMAND_LINE_SIZE 2048
+
 static unsigned long fs;
 static inline void set_fs(unsigned long seg)
 {
@@ -12,12 +14,32 @@ static inline char rdfs8(addr_t addr)
 	return *((char *)(fs + addr));
 }
 #include "../cmdline.c"
+
+#ifdef CONFIG_CMDLINE_BOOL
+static char builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE;
+static bool builtin_cmdline_init __section(".data");
+#endif
+
 unsigned long get_cmd_line_ptr(void)
 {
 	unsigned long cmd_line_ptr = boot_params->hdr.cmd_line_ptr;
-
 	cmd_line_ptr |= (u64)boot_params->ext_cmd_line_ptr << 32;
 
+#ifdef CONFIG_CMDLINE_BOOL
+	if (!builtin_cmdline_init) {
+		if (!IS_ENABLED(CONFIG_CMDLINE_OVERRIDE)) {
+			strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
+			strlcat(builtin_cmdline,
+				(char *)cmd_line_ptr,
+				COMMAND_LINE_SIZE);
+		}
+
+		builtin_cmdline_init = 1;
+	}
+
+	cmd_line_ptr = (unsigned long)builtin_cmdline;
+#endif
+
 	return cmd_line_ptr;
 }
 int cmdline_find_option(const char *option, char *buffer, int bufsize)
-- 
2.36.0

Powered by blists - more mailing lists