linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] init: Handle bootloader head in kernel parameters
@ 2025-07-11 10:24 Huacai Chen
  2025-07-11 11:06 ` Greg KH
  0 siblings, 1 reply; 11+ messages in thread
From: Huacai Chen @ 2025-07-11 10:24 UTC (permalink / raw)
  To: Huacai Chen, Andrew Morton
  Cc: linux-mm, Alexander Viro, Christian Brauner, Jan Kara,
	linux-kernel, Huacai Chen, stable

BootLoader may pass a head such as "BOOT_IMAGE=/boot/vmlinuz-x.y.z" to
kernel parameters. But this head is not recognized by the kernel so will
be passed to user space. However, user space init program also doesn't
recognized it.

KEXEC may also pass a head such as "kexec" on some architectures.

So the the best way is handle it by the kernel itself, which can avoid
such boot warnings:

Kernel command line: BOOT_IMAGE=(hd0,1)/vmlinuz-6.x root=/dev/sda3 ro console=tty
Unknown kernel command line parameters "BOOT_IMAGE=(hd0,1)/vmlinuz-6.x", will be passed to user space.

Cc: stable@vger.kernel.org
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
 init/main.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/init/main.c b/init/main.c
index 225a58279acd..9e0a7e8913c0 100644
--- a/init/main.c
+++ b/init/main.c
@@ -545,6 +545,7 @@ static int __init unknown_bootoption(char *param, char *val,
 				     const char *unused, void *arg)
 {
 	size_t len = strlen(param);
+	const char *bootloader[] = { "BOOT_IMAGE", "kexec", NULL };
 
 	/* Handle params aliased to sysctls */
 	if (sysctl_is_alias(param))
@@ -552,6 +553,12 @@ static int __init unknown_bootoption(char *param, char *val,
 
 	repair_env_string(param, val);
 
+	/* Handle bootloader head */
+	for (int i = 0; bootloader[i]; i++) {
+		if (!strncmp(param, bootloader[i], strlen(bootloader[i])))
+			return 0;
+	}
+
 	/* Handle obsolete-style parameters */
 	if (obsolete_checksetup(param))
 		return 0;
-- 
2.47.1



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

end of thread, other threads:[~2025-07-14 10:18 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-11 10:24 [PATCH] init: Handle bootloader head in kernel parameters Huacai Chen
2025-07-11 11:06 ` Greg KH
2025-07-11 12:34   ` Huacai Chen
2025-07-11 12:40     ` Greg KH
2025-07-11 12:51       ` Huacai Chen
2025-07-11 13:04         ` Greg KH
2025-07-12 15:18           ` Huacai Chen
2025-07-13  8:30             ` Greg KH
2025-07-13  9:11               ` Huacai Chen
2025-07-13  9:35                 ` Greg KH
2025-07-14 10:18                   ` Huacai Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).