public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] init: keep boot_command_line after init
@ 2023-07-26 14:33 Arnd Bergmann
  2023-07-26 16:25 ` Nick Desaulniers
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2023-07-26 14:33 UTC (permalink / raw)
  To: Paul E. McKenney
  Cc: Arnd Bergmann, Andrew Morton, Kees Cook, Peter Zijlstra (Intel),
	Sami Tolvanen, Alexey Dobriyan, Masahiro Yamada, Josh Poimboeuf,
	ndesaulniers@google.com, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

The boot command line is not available after the init section gets discarded,
so adding a permanent reference to it causes a link time warning:

WARNING: modpost: vmlinux: section mismatch in reference: cmdline_load_proc_show+0x2 (section: .text) -> boot_command_line (section: .init.data)
ERROR: modpost: Section mismatches detected.
Set CONFIG_SECTION_MISMATCH_WARN_ONLY=y to allow them.

Change it to __ro_after_init to prevent it from getting freed.

Fixes: cf9eca90a3397 ("fs/proc: Add /proc/cmdline_load for boot loader arguments")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 include/linux/init.h | 2 +-
 init/main.c          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/init.h b/include/linux/init.h
index 9a5973324072b..4e97a7a29a4d7 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -143,7 +143,7 @@ struct file_system_type;
 
 /* Defined in init/main.c */
 extern int do_one_initcall(initcall_t fn);
-extern char __initdata boot_command_line[];
+extern char boot_command_line[];
 extern char *saved_command_line;
 extern unsigned int saved_command_line_len;
 extern unsigned int reset_devices;
diff --git a/init/main.c b/init/main.c
index c946ab87783a1..981170da0b1cd 100644
--- a/init/main.c
+++ b/init/main.c
@@ -135,7 +135,7 @@ EXPORT_SYMBOL(system_state);
 void (*__initdata late_time_init)(void);
 
 /* Untouched command line saved by arch-specific code. */
-char __initdata boot_command_line[COMMAND_LINE_SIZE];
+char boot_command_line[COMMAND_LINE_SIZE] __ro_after_init;
 /* Untouched saved command line (eg. for /proc) */
 char *saved_command_line __ro_after_init;
 unsigned int saved_command_line_len __ro_after_init;
-- 
2.39.2


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

end of thread, other threads:[~2023-07-26 18:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-26 14:33 [PATCH] init: keep boot_command_line after init Arnd Bergmann
2023-07-26 16:25 ` Nick Desaulniers
2023-07-26 17:02   ` Arnd Bergmann
2023-07-26 18:53     ` Paul E. McKenney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox