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>] [day] [month] [year] [list]
Message-ID: <20250826002920.62397-1-makb@juniper.net>
Date: Mon, 25 Aug 2025 17:29:20 -0700
From: Brian Mak <makb@...iper.net>
To: Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
        Borislav Petkov <bp@...en8.de>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        "H. Peter Anvin" <hpa@...or.com>, <x86@...nel.org>,
        <linux-kernel@...r.kernel.org>
CC: Brian Mak <makb@...iper.net>
Subject: [PATCH] x86/boot: Add option to append to the cmdline

Currently, the bootloader-provided command line can be prepended to with
the built-in command line. This is done by enabling CONFIG_CMDLINE_BOOL
and specifying a CONFIG_CMDLINE value with CONFIG_CMDLINE_OVERRIDE
disabled.

However, there is currently no way to append the built-in command line
to the bootloader-provided command line, like there is on some other
architectures. This is necessary to work around bootloaders that are
difficult to update, where we want to override a subset of the
bootloader-provided values and keep the others.

To solve this limitation, we add CONFIG_CMDLINE_EXTEND, which is already
available on several other architectures, to make the built-in command
line append to the bootloader-provided command line.

Signed-off-by: Brian Mak <makb@...iper.net>
---
 arch/x86/Kconfig        |  9 +++++++++
 arch/x86/kernel/setup.c | 13 +++++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 58d890fe2100..8da39ebaddf4 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2275,6 +2275,15 @@ config CMDLINE_BOOL
 	  Systems with fully functional boot loaders (i.e. non-embedded)
 	  should leave this option set to 'N'.
 
+config CMDLINE_EXTEND
+	bool "Extend bootloader kernel arguments"
+	depends on CMDLINE_BOOL && !CMDLINE_OVERRIDE
+	help
+	  The built-in command line will be appended to the command-
+	  line arguments provided during boot. This is useful in
+	  cases where the provided arguments are insufficient and
+	  you don't want to or cannot modify them.
+
 config CMDLINE
 	string "Built-in kernel command string"
 	depends on CMDLINE_BOOL
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 1b2edd07a3e1..86e4d8ab8558 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -911,10 +911,15 @@ void __init setup_arch(char **cmdline_p)
 	strscpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
 #else
 	if (builtin_cmdline[0]) {
-		/* append boot loader cmdline to builtin */
-		strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
-		strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE);
-		strscpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
+		if (!IS_ENABLED(CONFIG_CMDLINE_EXTEND)) {
+			/* append boot loader cmdline to builtin */
+			strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
+			strlcat(builtin_cmdline, boot_command_line, COMMAND_LINE_SIZE);
+			strscpy(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
+		} else {
+			strlcat(boot_command_line, " ", COMMAND_LINE_SIZE);
+			strlcat(boot_command_line, builtin_cmdline, COMMAND_LINE_SIZE);
+		}
 	}
 #endif
 	builtin_cmdline_added = true;

base-commit: 1b237f190eb3d36f52dffe07a40b5eb210280e00
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ