* [PATCH v2 0/2] efi/libstub: fix efi_parse_options() ignoring the default command line
@ 2024-10-13 5:11 Jonathan Marek
2024-10-13 5:11 ` [PATCH v2 1/2] " Jonathan Marek
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Jonathan Marek @ 2024-10-13 5:11 UTC (permalink / raw)
To: linux-efi
Cc: Aditya Garg, Andrew Morton, Ard Biesheuvel, Borislav Petkov (AMD),
Ingo Molnar, Kees Cook, Kirill A. Shutemov,
Kuppuswamy Sathyanarayanan, open list, Nikolay Borisov
v2:
- changed to check for NUL character instead of size==1
- reworked cleanup patch to remove cmd_line_len
- moved 3rd commit out of this series
Jonathan Marek (2):
efi/libstub: fix efi_parse_options() ignoring the default command line
efi/libstub: remove unnecessary cmd_line_len from
efi_convert_cmdline()
drivers/firmware/efi/libstub/efi-stub-helper.c | 3 +--
drivers/firmware/efi/libstub/efi-stub.c | 7 +++----
drivers/firmware/efi/libstub/efistub.h | 2 +-
drivers/firmware/efi/libstub/x86-stub.c | 3 +--
4 files changed, 6 insertions(+), 9 deletions(-)
--
2.45.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/2] efi/libstub: fix efi_parse_options() ignoring the default command line
2024-10-13 5:11 [PATCH v2 0/2] efi/libstub: fix efi_parse_options() ignoring the default command line Jonathan Marek
@ 2024-10-13 5:11 ` Jonathan Marek
2024-10-13 5:11 ` [PATCH v2 2/2] efi/libstub: remove unnecessary cmd_line_len from efi_convert_cmdline() Jonathan Marek
2024-10-13 17:30 ` [PATCH v2 0/2] efi/libstub: fix efi_parse_options() ignoring the default command line Ard Biesheuvel
2 siblings, 0 replies; 6+ messages in thread
From: Jonathan Marek @ 2024-10-13 5:11 UTC (permalink / raw)
To: linux-efi
Cc: Ard Biesheuvel, Kuppuswamy Sathyanarayanan, Ingo Molnar, open list
efi_convert_cmdline() always returns a size of at least 1 because it counts
the NUL terminator, so the "cmdline_size == 0" condition is not possible.
Change it to check if the string starts with a NUL character to get the
intended behavior: to use CONFIG_CMDLINE when load_options_size is 0.
Fixes: 60f38de7a8d4 ("efi/libstub: Unify command line param parsing")
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
---
drivers/firmware/efi/libstub/efi-stub.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c
index 958a680e0660d..2a1b43f9e0fa2 100644
--- a/drivers/firmware/efi/libstub/efi-stub.c
+++ b/drivers/firmware/efi/libstub/efi-stub.c
@@ -129,7 +129,7 @@ efi_status_t efi_handle_cmdline(efi_loaded_image_t *image, char **cmdline_ptr)
if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) ||
IS_ENABLED(CONFIG_CMDLINE_FORCE) ||
- cmdline_size == 0) {
+ cmdline[0] == 0) {
status = efi_parse_options(CONFIG_CMDLINE);
if (status != EFI_SUCCESS) {
efi_err("Failed to parse options\n");
--
2.45.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] efi/libstub: remove unnecessary cmd_line_len from efi_convert_cmdline()
2024-10-13 5:11 [PATCH v2 0/2] efi/libstub: fix efi_parse_options() ignoring the default command line Jonathan Marek
2024-10-13 5:11 ` [PATCH v2 1/2] " Jonathan Marek
@ 2024-10-13 5:11 ` Jonathan Marek
2024-10-13 17:30 ` [PATCH v2 0/2] efi/libstub: fix efi_parse_options() ignoring the default command line Ard Biesheuvel
2 siblings, 0 replies; 6+ messages in thread
From: Jonathan Marek @ 2024-10-13 5:11 UTC (permalink / raw)
To: linux-efi
Cc: Ard Biesheuvel, Kuppuswamy Sathyanarayanan, Borislav Petkov (AMD),
Kirill A. Shutemov, Kees Cook, Aditya Garg, Nikolay Borisov,
open list
efi_convert_cmdline() always sets cmdline_size to at least 1 on success,
so the "cmdline_size > 0" does nothing and can be removed (the intent was
to avoid parsing an empty string, but there is nothing wrong with parsing
an empty string, it is only making boot negligibly slower).
Then the cmd_line_len argument to efi_convert_cmdline can be removed
because there is nothing left using it.
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
---
drivers/firmware/efi/libstub/efi-stub-helper.c | 3 +--
drivers/firmware/efi/libstub/efi-stub.c | 5 ++---
drivers/firmware/efi/libstub/efistub.h | 2 +-
drivers/firmware/efi/libstub/x86-stub.c | 3 +--
4 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
index de659f6a815fd..e7346f8edb38c 100644
--- a/drivers/firmware/efi/libstub/efi-stub-helper.c
+++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
@@ -327,7 +327,7 @@ static efi_status_t efi_measure_tagged_event(unsigned long load_addr,
* Size of memory allocated return in *cmd_line_len.
* Returns NULL on error.
*/
-char *efi_convert_cmdline(efi_loaded_image_t *image, int *cmd_line_len)
+char *efi_convert_cmdline(efi_loaded_image_t *image)
{
const efi_char16_t *options = efi_table_attr(image, load_options);
u32 options_size = efi_table_attr(image, load_options_size);
@@ -405,7 +405,6 @@ char *efi_convert_cmdline(efi_loaded_image_t *image, int *cmd_line_len)
snprintf((char *)cmdline_addr, options_bytes, "%.*ls",
options_bytes - 1, options);
- *cmd_line_len = options_bytes;
return (char *)cmdline_addr;
}
diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c
index 2a1b43f9e0fa2..f09e277ba2108 100644
--- a/drivers/firmware/efi/libstub/efi-stub.c
+++ b/drivers/firmware/efi/libstub/efi-stub.c
@@ -112,7 +112,6 @@ static u32 get_supported_rt_services(void)
efi_status_t efi_handle_cmdline(efi_loaded_image_t *image, char **cmdline_ptr)
{
- int cmdline_size = 0;
efi_status_t status;
char *cmdline;
@@ -121,7 +120,7 @@ efi_status_t efi_handle_cmdline(efi_loaded_image_t *image, char **cmdline_ptr)
* protocol. We are going to copy the command line into the
* device tree, so this can be allocated anywhere.
*/
- cmdline = efi_convert_cmdline(image, &cmdline_size);
+ cmdline = efi_convert_cmdline(image);
if (!cmdline) {
efi_err("getting command line via LOADED_IMAGE_PROTOCOL\n");
return EFI_OUT_OF_RESOURCES;
@@ -137,7 +136,7 @@ efi_status_t efi_handle_cmdline(efi_loaded_image_t *image, char **cmdline_ptr)
}
}
- if (!IS_ENABLED(CONFIG_CMDLINE_FORCE) && cmdline_size > 0) {
+ if (!IS_ENABLED(CONFIG_CMDLINE_FORCE)) {
status = efi_parse_options(cmdline);
if (status != EFI_SUCCESS) {
efi_err("Failed to parse options\n");
diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h
index 685098f9626f2..76e44c185f29e 100644
--- a/drivers/firmware/efi/libstub/efistub.h
+++ b/drivers/firmware/efi/libstub/efistub.h
@@ -1056,7 +1056,7 @@ void efi_free(unsigned long size, unsigned long addr);
void efi_apply_loadoptions_quirk(const void **load_options, u32 *load_options_size);
-char *efi_convert_cmdline(efi_loaded_image_t *image, int *cmd_line_len);
+char *efi_convert_cmdline(efi_loaded_image_t *image);
efi_status_t efi_get_memory_map(struct efi_boot_memmap **map,
bool install_cfg_tbl);
diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
index f8e465da344d5..188c8000d245e 100644
--- a/drivers/firmware/efi/libstub/x86-stub.c
+++ b/drivers/firmware/efi/libstub/x86-stub.c
@@ -537,7 +537,6 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
efi_guid_t proto = LOADED_IMAGE_PROTOCOL_GUID;
struct boot_params *boot_params;
struct setup_header *hdr;
- int options_size = 0;
efi_status_t status;
unsigned long alloc;
char *cmdline_ptr;
@@ -569,7 +568,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
hdr->initrd_addr_max = INT_MAX;
/* Convert unicode cmdline to ascii */
- cmdline_ptr = efi_convert_cmdline(image, &options_size);
+ cmdline_ptr = efi_convert_cmdline(image);
if (!cmdline_ptr) {
efi_free(PARAM_SIZE, alloc);
efi_exit(handle, EFI_OUT_OF_RESOURCES);
--
2.45.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 0/2] efi/libstub: fix efi_parse_options() ignoring the default command line
2024-10-13 5:11 [PATCH v2 0/2] efi/libstub: fix efi_parse_options() ignoring the default command line Jonathan Marek
2024-10-13 5:11 ` [PATCH v2 1/2] " Jonathan Marek
2024-10-13 5:11 ` [PATCH v2 2/2] efi/libstub: remove unnecessary cmd_line_len from efi_convert_cmdline() Jonathan Marek
@ 2024-10-13 17:30 ` Ard Biesheuvel
2024-10-13 19:22 ` Jonathan Marek
2 siblings, 1 reply; 6+ messages in thread
From: Ard Biesheuvel @ 2024-10-13 17:30 UTC (permalink / raw)
To: Jonathan Marek
Cc: linux-efi, Aditya Garg, Andrew Morton, Borislav Petkov (AMD),
Ingo Molnar, Kees Cook, Kirill A. Shutemov,
Kuppuswamy Sathyanarayanan, open list, Nikolay Borisov
On Sun, 13 Oct 2024 at 07:16, Jonathan Marek <jonathan@marek.ca> wrote:
>
> v2:
> - changed to check for NUL character instead of size==1
> - reworked cleanup patch to remove cmd_line_len
> - moved 3rd commit out of this series
>
> Jonathan Marek (2):
> efi/libstub: fix efi_parse_options() ignoring the default command line
> efi/libstub: remove unnecessary cmd_line_len from
> efi_convert_cmdline()
>
Thanks. I'm inclined to fold these together and just merge them as a
single patch. Any objections?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 0/2] efi/libstub: fix efi_parse_options() ignoring the default command line
2024-10-13 17:30 ` [PATCH v2 0/2] efi/libstub: fix efi_parse_options() ignoring the default command line Ard Biesheuvel
@ 2024-10-13 19:22 ` Jonathan Marek
2024-10-14 9:55 ` Ard Biesheuvel
0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Marek @ 2024-10-13 19:22 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: linux-efi, Aditya Garg, Andrew Morton, Borislav Petkov (AMD),
Ingo Molnar, Kees Cook, Kirill A. Shutemov,
Kuppuswamy Sathyanarayanan, open list, Nikolay Borisov
On 10/13/24 1:30 PM, Ard Biesheuvel wrote:
> On Sun, 13 Oct 2024 at 07:16, Jonathan Marek <jonathan@marek.ca> wrote:
>>
>> v2:
>> - changed to check for NUL character instead of size==1
>> - reworked cleanup patch to remove cmd_line_len
>> - moved 3rd commit out of this series
>>
>> Jonathan Marek (2):
>> efi/libstub: fix efi_parse_options() ignoring the default command line
>> efi/libstub: remove unnecessary cmd_line_len from
>> efi_convert_cmdline()
>>
>
> Thanks. I'm inclined to fold these together and just merge them as a
> single patch. Any objections?
>
No objections (its not important to me, but if you want to get the fix
into stable I think the separate commits makes that easier?)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 0/2] efi/libstub: fix efi_parse_options() ignoring the default command line
2024-10-13 19:22 ` Jonathan Marek
@ 2024-10-14 9:55 ` Ard Biesheuvel
0 siblings, 0 replies; 6+ messages in thread
From: Ard Biesheuvel @ 2024-10-14 9:55 UTC (permalink / raw)
To: Jonathan Marek
Cc: linux-efi, Aditya Garg, Andrew Morton, Borislav Petkov (AMD),
Ingo Molnar, Kees Cook, Kirill A. Shutemov,
Kuppuswamy Sathyanarayanan, open list, Nikolay Borisov
On Sun, 13 Oct 2024 at 21:25, Jonathan Marek <jonathan@marek.ca> wrote:
>
> On 10/13/24 1:30 PM, Ard Biesheuvel wrote:
> > On Sun, 13 Oct 2024 at 07:16, Jonathan Marek <jonathan@marek.ca> wrote:
> >>
> >> v2:
> >> - changed to check for NUL character instead of size==1
> >> - reworked cleanup patch to remove cmd_line_len
> >> - moved 3rd commit out of this series
> >>
> >> Jonathan Marek (2):
> >> efi/libstub: fix efi_parse_options() ignoring the default command line
> >> efi/libstub: remove unnecessary cmd_line_len from
> >> efi_convert_cmdline()
> >>
> >
> > Thanks. I'm inclined to fold these together and just merge them as a
> > single patch. Any objections?
> >
>
> No objections (its not important to me, but if you want to get the fix
> into stable I think the separate commits makes that easier?)
Yeah good point. I am not going to send these out as fixes anyway,
given that they affect boot behavior, and there are some other things
to fix.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-10-14 9:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-13 5:11 [PATCH v2 0/2] efi/libstub: fix efi_parse_options() ignoring the default command line Jonathan Marek
2024-10-13 5:11 ` [PATCH v2 1/2] " Jonathan Marek
2024-10-13 5:11 ` [PATCH v2 2/2] efi/libstub: remove unnecessary cmd_line_len from efi_convert_cmdline() Jonathan Marek
2024-10-13 17:30 ` [PATCH v2 0/2] efi/libstub: fix efi_parse_options() ignoring the default command line Ard Biesheuvel
2024-10-13 19:22 ` Jonathan Marek
2024-10-14 9:55 ` Ard Biesheuvel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®