* [PATCH 1/3] efi: pstore: Request at most 512 bytes for variable names
@ 2024-03-15 0:25 Tim Schumacher
2024-03-15 9:16 ` Ard Biesheuvel
2024-03-28 20:50 ` [PATCH v2 1/4] " Tim Schumacher
0 siblings, 2 replies; 7+ messages in thread
From: Tim Schumacher @ 2024-03-15 0:25 UTC (permalink / raw)
To: linux-efi
Cc: Tim Schumacher, Kees Cook, Tony Luck, Guilherme G. Piccoli,
Ard Biesheuvel, linux-hardening
Work around a quirk in a few old (2011-ish) UEFI implementations, where
a call to `GetNextVariableName` with a buffer size larger than 512 bytes
will always return EFI_INVALID_PARAMETER.
This was already done to efivarfs in f45812cc23fb ("efivarfs: Request at
most 512 bytes for variable names"), but the second copy of the variable
iteration implementation was overlooked.
Signed-off-by: Tim Schumacher <timschumi@gmx.de>
---
I CC'd the pstore people and linux-hardening mailing list because
get_maintainer.pl suggested to do so. Apologies in case this was the
incorrect decision, this is a very non-pstore-specific patch after all.
I have taken the liberty of adding a TODO for the future, the actual
refactor can follow at some point down the line.
---
drivers/firmware/efi/efi-pstore.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c
index e7b9ec6f8a86..f0ceb5702d21 100644
--- a/drivers/firmware/efi/efi-pstore.c
+++ b/drivers/firmware/efi/efi-pstore.c
@@ -135,7 +135,15 @@ static ssize_t efi_pstore_read(struct pstore_record *record)
efi_status_t status;
for (;;) {
- varname_size = 1024;
+ /*
+ * A small set of old UEFI implementations reject sizes
+ * above a certain threshold, the lowest seen in the wild
+ * is 512.
+ *
+ * TODO: Commonize with the iteration implementation in
+ * fs/efivarfs to keep all the quirks in one place.
+ */
+ varname_size = 512;
/*
* If this is the first read() call in the pstore enumeration,
--
2.44.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] efi: pstore: Request at most 512 bytes for variable names
2024-03-15 0:25 [PATCH 1/3] efi: pstore: Request at most 512 bytes for variable names Tim Schumacher
@ 2024-03-15 9:16 ` Ard Biesheuvel
2024-03-15 19:02 ` Tim Schumacher
2024-03-15 19:45 ` Guilherme G. Piccoli
2024-03-28 20:50 ` [PATCH v2 1/4] " Tim Schumacher
1 sibling, 2 replies; 7+ messages in thread
From: Ard Biesheuvel @ 2024-03-15 9:16 UTC (permalink / raw)
To: Tim Schumacher
Cc: linux-efi, Kees Cook, Tony Luck, Guilherme G. Piccoli,
linux-hardening
Hi Tim,
On Fri, 15 Mar 2024 at 01:27, Tim Schumacher <timschumi@gmx.de> wrote:
>
> Work around a quirk in a few old (2011-ish) UEFI implementations, where
> a call to `GetNextVariableName` with a buffer size larger than 512 bytes
> will always return EFI_INVALID_PARAMETER.
>
> This was already done to efivarfs in f45812cc23fb ("efivarfs: Request at
> most 512 bytes for variable names"), but the second copy of the variable
> iteration implementation was overlooked.
>
> Signed-off-by: Tim Schumacher <timschumi@gmx.de>
Thanks for the patch. I'll take it as a fix.
As an aside, you really want to avoid EFI pstore in general, and
specifically on such old systems with quirky UEFI implementations.
> ---
> I CC'd the pstore people and linux-hardening mailing list because
> get_maintainer.pl suggested to do so. Apologies in case this was the
> incorrect decision, this is a very non-pstore-specific patch after all.
>
If any of the linux-hardening/pstore people give you grief, just send
them to me :-)
(I am part of the linux-hardening group myself, and work closely with Kees)
> I have taken the liberty of adding a TODO for the future, the actual
> refactor can follow at some point down the line.
> ---
> drivers/firmware/efi/efi-pstore.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c
> index e7b9ec6f8a86..f0ceb5702d21 100644
> --- a/drivers/firmware/efi/efi-pstore.c
> +++ b/drivers/firmware/efi/efi-pstore.c
> @@ -135,7 +135,15 @@ static ssize_t efi_pstore_read(struct pstore_record *record)
> efi_status_t status;
>
> for (;;) {
> - varname_size = 1024;
> + /*
> + * A small set of old UEFI implementations reject sizes
> + * above a certain threshold, the lowest seen in the wild
> + * is 512.
> + *
> + * TODO: Commonize with the iteration implementation in
> + * fs/efivarfs to keep all the quirks in one place.
> + */
> + varname_size = 512;
>
> /*
> * If this is the first read() call in the pstore enumeration,
> --
> 2.44.0
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] efi: pstore: Request at most 512 bytes for variable names
2024-03-15 9:16 ` Ard Biesheuvel
@ 2024-03-15 19:02 ` Tim Schumacher
2024-03-15 19:45 ` Guilherme G. Piccoli
1 sibling, 0 replies; 7+ messages in thread
From: Tim Schumacher @ 2024-03-15 19:02 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: linux-efi, Kees Cook, Tony Luck, Guilherme G. Piccoli,
linux-hardening
On 15.03.24 10:16, Ard Biesheuvel wrote:
> Hi Tim,
>
> On Fri, 15 Mar 2024 at 01:27, Tim Schumacher <timschumi@gmx.de> wrote:
>>
>> Work around a quirk in a few old (2011-ish) UEFI implementations, where
>> a call to `GetNextVariableName` with a buffer size larger than 512 bytes
>> will always return EFI_INVALID_PARAMETER.
>>
>> This was already done to efivarfs in f45812cc23fb ("efivarfs: Request at
>> most 512 bytes for variable names"), but the second copy of the variable
>> iteration implementation was overlooked.
>>
>> Signed-off-by: Tim Schumacher <timschumi@gmx.de>
>
> Thanks for the patch. I'll take it as a fix.
>
> As an aside, you really want to avoid EFI pstore in general, and
> specifically on such old systems with quirky UEFI implementations.
>
I found this by chance while looking for appearances of the magic value of
1024, and decided to split it out because this would have been the only change
that modifies behavior.
I didn't intend to actually use it after fixing it up, although I did make sure
that it now does more than it did previously. If we can save someone a confused
"Why is this done differently here?" (and have a reason to boil down the code to
a single implementation in the future), then that is probably good enough on its
own.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] efi: pstore: Request at most 512 bytes for variable names
2024-03-15 9:16 ` Ard Biesheuvel
2024-03-15 19:02 ` Tim Schumacher
@ 2024-03-15 19:45 ` Guilherme G. Piccoli
2024-03-29 7:34 ` Ard Biesheuvel
1 sibling, 1 reply; 7+ messages in thread
From: Guilherme G. Piccoli @ 2024-03-15 19:45 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: linux-efi, Tim Schumacher, Kees Cook, Tony Luck, linux-hardening
On 15/03/2024 06:16, Ard Biesheuvel wrote:
> [...]
> As an aside, you really want to avoid EFI pstore in general, and
> specifically on such old systems with quirky UEFI implementations.
>
Hi Ard, this comment made me very curious; apart from old quirky UEFI
implementations, what's the reason you see to avoid using efi-pstore in
general ?
Thanks in advance for your insights!
Cheers,
Guilherme
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/4] efi: pstore: Request at most 512 bytes for variable names
2024-03-15 0:25 [PATCH 1/3] efi: pstore: Request at most 512 bytes for variable names Tim Schumacher
2024-03-15 9:16 ` Ard Biesheuvel
@ 2024-03-28 20:50 ` Tim Schumacher
1 sibling, 0 replies; 7+ messages in thread
From: Tim Schumacher @ 2024-03-28 20:50 UTC (permalink / raw)
To: linux-efi
Cc: Tim Schumacher, Ard Biesheuvel, linux-hardening, Kees Cook,
Tony Luck, Guilherme G. Piccoli
Work around a quirk in a few old (2011-ish) UEFI implementations, where
a call to `GetNextVariableName` with a buffer size larger than 512 bytes
will always return EFI_INVALID_PARAMETER.
This was already done to efivarfs in commit f45812cc23fb ("efivarfs:
Request at most 512 bytes for variable names"), but the second copy of
the variable iteration implementation was overlooked.
Signed-off-by: Tim Schumacher <timschumi@gmx.de>
---
Changes from v1:
- None, resubmitted as a part of a chain.
---
drivers/firmware/efi/efi-pstore.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c
index 833cbb995dd3f..5b9dc26e6bcb9 100644
--- a/drivers/firmware/efi/efi-pstore.c
+++ b/drivers/firmware/efi/efi-pstore.c
@@ -162,7 +162,15 @@ static ssize_t efi_pstore_read(struct pstore_record *record)
efi_status_t status;
for (;;) {
- varname_size = 1024;
+ /*
+ * A small set of old UEFI implementations reject sizes
+ * above a certain threshold, the lowest seen in the wild
+ * is 512.
+ *
+ * TODO: Commonize with the iteration implementation in
+ * fs/efivarfs to keep all the quirks in one place.
+ */
+ varname_size = 512;
/*
* If this is the first read() call in the pstore enumeration,
--
2.44.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] efi: pstore: Request at most 512 bytes for variable names
2024-03-15 19:45 ` Guilherme G. Piccoli
@ 2024-03-29 7:34 ` Ard Biesheuvel
2024-03-29 21:32 ` Guilherme G. Piccoli
0 siblings, 1 reply; 7+ messages in thread
From: Ard Biesheuvel @ 2024-03-29 7:34 UTC (permalink / raw)
To: Guilherme G. Piccoli
Cc: linux-efi, Tim Schumacher, Kees Cook, Tony Luck, linux-hardening
On Fri, 15 Mar 2024 at 21:46, Guilherme G. Piccoli <gpiccoli@igalia.com> wrote:
>
> On 15/03/2024 06:16, Ard Biesheuvel wrote:
> > [...]
> > As an aside, you really want to avoid EFI pstore in general, and
> > specifically on such old systems with quirky UEFI implementations.
> >
>
> Hi Ard, this comment made me very curious; apart from old quirky UEFI
> implementations, what's the reason you see to avoid using efi-pstore in
> general ?
>
> Thanks in advance for your insights!
I'm just not impressed by the general quality of implementations -
relying on this when the system is going down is a reasonable last
resort, perhaps, but if other options are available, I'd prioritize
those.
And this is for the oops/panic logs only - other uses of pstore seem
better served with ordinary file based persistence.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] efi: pstore: Request at most 512 bytes for variable names
2024-03-29 7:34 ` Ard Biesheuvel
@ 2024-03-29 21:32 ` Guilherme G. Piccoli
0 siblings, 0 replies; 7+ messages in thread
From: Guilherme G. Piccoli @ 2024-03-29 21:32 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: linux-efi, Tim Schumacher, Kees Cook, Tony Luck, linux-hardening
On 29/03/2024 04:34, Ard Biesheuvel wrote:
> [...]
>
> I'm just not impressed by the general quality of implementations -
> relying on this when the system is going down is a reasonable last
> resort, perhaps, but if other options are available, I'd prioritize
> those.
>
> And this is for the oops/panic logs only - other uses of pstore seem
> better served with ordinary file based persistence.
OK, I understand now.
Thanks,
Guilherme
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-03-29 21:32 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-15 0:25 [PATCH 1/3] efi: pstore: Request at most 512 bytes for variable names Tim Schumacher
2024-03-15 9:16 ` Ard Biesheuvel
2024-03-15 19:02 ` Tim Schumacher
2024-03-15 19:45 ` Guilherme G. Piccoli
2024-03-29 7:34 ` Ard Biesheuvel
2024-03-29 21:32 ` Guilherme G. Piccoli
2024-03-28 20:50 ` [PATCH v2 1/4] " Tim Schumacher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox