Skip to content

Commit e6384c3

Browse files
committed
efi/libstub: Parse builtin command line after bootloader provided one
When CONFIG_CMDLINE_EXTEND is set, the core kernel command line handling logic appends CONFIG_CMDLINE to the bootloader provided command line. The EFI stub does the opposite, and parses the builtin one first. The usual behavior of command line options is that the last one takes precedence if it appears multiple times, unless there is a meaningful way to combine them. In either case, parsing the builtin command line first while the core kernel does it in the opposite order is likely to produce inconsistent results in such cases. Therefore, switch the order in the stub to match the core kernel. Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 parent 21b1a7f commit e6384c3

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

drivers/firmware/efi/libstub/efi-stub.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,28 +126,25 @@ efi_status_t efi_handle_cmdline(efi_loaded_image_t *image, char **cmdline_ptr)
126126
return EFI_OUT_OF_RESOURCES;
127127
}
128128

129+
if (!IS_ENABLED(CONFIG_CMDLINE_FORCE)) {
130+
status = efi_parse_options(cmdline);
131+
if (status != EFI_SUCCESS)
132+
goto fail_free_cmdline;
133+
}
134+
129135
if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) ||
130136
IS_ENABLED(CONFIG_CMDLINE_FORCE) ||
131137
cmdline[0] == 0) {
132138
status = efi_parse_options(CONFIG_CMDLINE);
133-
if (status != EFI_SUCCESS) {
134-
efi_err("Failed to parse options\n");
135-
goto fail_free_cmdline;
136-
}
137-
}
138-
139-
if (!IS_ENABLED(CONFIG_CMDLINE_FORCE)) {
140-
status = efi_parse_options(cmdline);
141-
if (status != EFI_SUCCESS) {
142-
efi_err("Failed to parse options\n");
139+
if (status != EFI_SUCCESS)
143140
goto fail_free_cmdline;
144-
}
145141
}
146142

147143
*cmdline_ptr = cmdline;
148144
return EFI_SUCCESS;
149145

150146
fail_free_cmdline:
147+
efi_err("Failed to parse options\n");
151148
efi_bs_call(free_pool, cmdline);
152149
return status;
153150
}

0 commit comments

Comments
 (0)