From: Arnd Bergmann <arnd@kernel.org>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
Andrew Morton <akpm@linux-foundation.org>,
Kees Cook <keescook@chromium.org>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
Sami Tolvanen <samitolvanen@google.com>,
Alexey Dobriyan <adobriyan@gmail.com>,
Masahiro Yamada <masahiroy@kernel.org>,
Josh Poimboeuf <jpoimboe@kernel.org>,
"ndesaulniers@google.com" <ndesaulniers@google.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH] init: keep boot_command_line after init
Date: Wed, 26 Jul 2023 16:33:21 +0200 [thread overview]
Message-ID: <20230726143348.724611-1-arnd@kernel.org> (raw)
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
next reply other threads:[~2023-07-26 14:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-26 14:33 Arnd Bergmann [this message]
2023-07-26 16:25 ` [PATCH] init: keep boot_command_line after init Nick Desaulniers
2023-07-26 17:02 ` Arnd Bergmann
2023-07-26 18:53 ` Paul E. McKenney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230726143348.724611-1-arnd@kernel.org \
--to=arnd@kernel.org \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=jpoimboe@kernel.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=ndesaulniers@google.com \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=samitolvanen@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox