[GIT PULL] bootconfig: Fixes for v6.9-rc3

From: Google
Date: Wed Apr 10 2024 - 21:06:45 EST


Hi Linus,

Bootconfig fixes for v6.9-rc3:

- fs/proc: Fix to not show original kernel cmdline more than twice on
/proc/bootconfig.
- fs/proc: Fix to show the original cmdline only if the bootconfig
modifies it.


Please pull the latest bootconfig-fixes-v6.9-rc3 tree, which can be found at:


git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
bootconfig-fixes-v6.9-rc3

Tag SHA1: b0066d569a0eed92657edc836868122a6761da49
Head SHA1: c722cea208789d9e2660992bcd05fb9fac3adb56


Masami Hiramatsu (1):
fs/proc: Skip bootloader comment if no embedded kernel parameters

Zhenhua Huang (1):
fs/proc: remove redundant comments from /proc/bootconfig

----
fs/proc/bootconfig.c | 12 ++++++------
include/linux/bootconfig.h | 1 +
init/main.c | 5 +++++
3 files changed, 12 insertions(+), 6 deletions(-)
---------------------------
diff --git a/fs/proc/bootconfig.c b/fs/proc/bootconfig.c
index 902b326e1e56..87dcaae32ff8 100644
--- a/fs/proc/bootconfig.c
+++ b/fs/proc/bootconfig.c
@@ -62,12 +62,12 @@ static int __init copy_xbc_key_value_list(char *dst, size_t size)
break;
dst += ret;
}
- if (ret >= 0 && boot_command_line[0]) {
- ret = snprintf(dst, rest(dst, end), "# Parameters from bootloader:\n# %s\n",
- boot_command_line);
- if (ret > 0)
- dst += ret;
- }
+ }
+ if (cmdline_has_extra_options() && ret >= 0 && boot_command_line[0]) {
+ ret = snprintf(dst, rest(dst, end), "# Parameters from bootloader:\n# %s\n",
+ boot_command_line);
+ if (ret > 0)
+ dst += ret;
}
out:
kfree(key);
diff --git a/include/linux/bootconfig.h b/include/linux/bootconfig.h
index ca73940e26df..e5ee2c694401 100644
--- a/include/linux/bootconfig.h
+++ b/include/linux/bootconfig.h
@@ -10,6 +10,7 @@
#ifdef __KERNEL__
#include <linux/kernel.h>
#include <linux/types.h>
+bool __init cmdline_has_extra_options(void);
#else /* !__KERNEL__ */
/*
* NOTE: This is only for tools/bootconfig, because tools/bootconfig will
diff --git a/init/main.c b/init/main.c
index 2ca52474d0c3..881f6230ee59 100644
--- a/init/main.c
+++ b/init/main.c
@@ -487,6 +487,11 @@ static int __init warn_bootconfig(char *str)

early_param("bootconfig", warn_bootconfig);

+bool __init cmdline_has_extra_options(void)
+{
+ return extra_command_line || extra_init_args;
+}
+
/* Change NUL term back to "=", to make "param" the whole string. */
static void __init repair_env_string(char *param, char *val)
{

--
Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>