Skip to contentSkip to conversation

init/bootconfig: pass init arguments in documented order

PATCH In review Avi Weiss 2 participants 3 messages Oct 27 – Oct 29 Tracing

lore
Share & tools
lore

Avi Weiss

author
#0 lore raw

PATCH 1/1 init/bootconfig: pass init arguments in documented order

start_kernel() appends command-line init arguments before bootconfig init arguments, while setup_command_line() places them in the opposite order. As a result, the arguments passed to init do not match the saved command line, reversing the intended precedence of options.

Parse extra_init_args before after_dashes so command-line init arguments are passed last.

Fixes 1319916209ce ("bootconfig: init: Allow admin to use bootconfig for init command line")
---
 init/main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
init/main.c +3 -3
index 27f4cb392349..3a270bb96aed 100644
@@ -1089,12 +1089,12 @@ void start_kernel(void)
 				  __stop___param - __start___param,
 				  -1, -1, NULL, &unknown_bootoption);
 	print_unknown_bootoptions();
-	if (!IS_ERR_OR_NULL(after_dashes))
-		parse_args("Setting init args", after_dashes, NULL, 0, -1, -1,
-			   NULL, set_init_arg);
 	if (extra_init_args)
 		parse_args("Setting extra init args", extra_init_args,
 			   NULL, 0, -1, -1, NULL, set_init_arg);
+	if (!IS_ERR_OR_NULL(after_dashes))
+		parse_args("Setting init args", after_dashes, NULL, 0, -1, -1,
+			   NULL, set_init_arg);
 
 	/* Architectural and non-timekeeping rng init, before allocator init */
 	random_init_early(command_line);

base-commit: d135ab453a7400a34930bdda1ef4bdc8acfac80e

Signature · 1 line
2.43.0
#1 lore raw

On Tue, 27 Oct 2026 09:37:20 +0200, Avi Weiss <[email protected]> wrote:

Hi Avi,

Thanks for fixing this! This looks good to me. Let me pick it.

Quoted 10 lines

start_kernel() appends command-line init arguments before bootconfig init arguments, while setup_command_line() places them in the opposite order. As a result, the arguments passed to init do not match the saved command line, reversing the intended precedence of options.

Parse extra_init_args before after_dashes so command-line init arguments are passed last.

Fixes 1319916209ce ("bootconfig: init: Allow admin to use bootconfig for init command line")

BTW, the Fixes: tag should point to commit b66fbbe8d482 ("init/bootconfig:
Reorder init parameter from bootconfig and cmdline").

In commit 1319916209ce, both setup_command_line() and start_kernel() placed extra_init_args after command-line args. It was commit b66fbbe8d482 that reordered setup_command_line() so that command-line init arguments come last (to allow cmdline to override bootconfig), but missed reordering start_kernel().

Thus I will change the Fixes tag as below.

Fixes b66fbbe8d482 ("init/bootconfig: Reorder init parameter from bootconfig and cmdline")
Quoted 5 lines
---
 init/main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Thanks!

Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
author
#2 lore raw

Cool no worries. Makes sense.
Thanks Masami

Quoted 42 lines · Masami Hiramatsu (Google)

On Tue, 27 Oct 2026 09:37:20 +0200, Avi Weiss <[email protected]> wrote:

Hi Avi,

Thanks for fixing this! This looks good to me. Let me pick it.

Quoted 10 lines

start_kernel() appends command-line init arguments before bootconfig init arguments, while setup_command_line() places them in the opposite order. As a result, the arguments passed to init do not match the saved command line, reversing the intended precedence of options.

Parse extra_init_args before after_dashes so command-line init arguments are passed last.

Fixes 1319916209ce ("bootconfig: init: Allow admin to use bootconfig for init command line")

BTW, the Fixes: tag should point to commit b66fbbe8d482 ("init/bootconfig:
Reorder init parameter from bootconfig and cmdline").

In commit 1319916209ce, both setup_command_line() and start_kernel() placed extra_init_args after command-line args. It was commit b66fbbe8d482 that reordered setup_command_line() so that command-line init arguments come last (to allow cmdline to override bootconfig), but missed reordering start_kernel().

Thus I will change the Fixes tag as below.

Fixes b66fbbe8d482 ("init/bootconfig: Reorder init parameter from bootconfig and cmdline")
Quoted 5 lines
---
 init/main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Thanks!

--
Masami Hiramatsu (Google) <[email protected]>