From: Ard Biesheuvel <ardb+git@google.com>
To: linux-efi@vger.kernel.org
Cc: Jonathan Marek <jonathan@marek.ca>, Ard Biesheuvel <ardb@kernel.org>
Subject: [PATCH 2/4] efi/libstub: Parse builtin command line after bootloader provided one
Date: Fri, 15 Nov 2024 10:28:40 +0100 [thread overview]
Message-ID: <20241115092838.3080857-6-ardb+git@google.com> (raw)
In-Reply-To: <20241115092838.3080857-5-ardb+git@google.com>
From: Ard Biesheuvel <ardb@kernel.org>
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>
---
drivers/firmware/efi/libstub/efi-stub.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c
index fc71dcab43e0..382b54f40603 100644
--- a/drivers/firmware/efi/libstub/efi-stub.c
+++ b/drivers/firmware/efi/libstub/efi-stub.c
@@ -126,28 +126,25 @@ efi_status_t efi_handle_cmdline(efi_loaded_image_t *image, char **cmdline_ptr)
return EFI_OUT_OF_RESOURCES;
}
+ if (!IS_ENABLED(CONFIG_CMDLINE_FORCE)) {
+ status = efi_parse_options(cmdline);
+ if (status != EFI_SUCCESS)
+ goto fail_free_cmdline;
+ }
+
if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) ||
IS_ENABLED(CONFIG_CMDLINE_FORCE) ||
cmdline[0] == 0) {
status = efi_parse_options(CONFIG_CMDLINE);
- if (status != EFI_SUCCESS) {
- efi_err("Failed to parse options\n");
- goto fail_free_cmdline;
- }
- }
-
- if (!IS_ENABLED(CONFIG_CMDLINE_FORCE)) {
- status = efi_parse_options(cmdline);
- if (status != EFI_SUCCESS) {
- efi_err("Failed to parse options\n");
+ if (status != EFI_SUCCESS)
goto fail_free_cmdline;
- }
}
*cmdline_ptr = cmdline;
return EFI_SUCCESS;
fail_free_cmdline:
+ efi_err("Failed to parse options\n");
efi_bs_call(free_pool, cmdline);
return status;
}
--
2.47.0.338.g60cca15819-goog
next prev parent reply other threads:[~2024-11-15 9:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-15 9:28 [PATCH 1/4] efi/libstub: Free correct pointer on failure Ard Biesheuvel
2024-11-15 9:28 ` Ard Biesheuvel [this message]
2024-11-15 9:28 ` [PATCH 3/4] efi/libstub: Fix command line fallback handling when loading files Ard Biesheuvel
2024-11-15 9:28 ` [PATCH 4/4] efi/libstub: Take command line overrides into account for loaded files Ard Biesheuvel
-- strict thread matches above, loose matches on Subject: below --
2024-10-15 18:15 [PATCH 0/4] efi/libstub: Clean up command line handling Ard Biesheuvel
2024-10-15 18:15 ` [PATCH 2/4] efi/libstub: Parse builtin command line after bootloader provided one Ard Biesheuvel
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=20241115092838.3080857-6-ardb+git@google.com \
--to=ardb+git@google.com \
--cc=ardb@kernel.org \
--cc=jonathan@marek.ca \
--cc=linux-efi@vger.kernel.org \
/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