* [PATCH] efi: pstore: Return proper errors on UEFI failures
@ 2024-05-19 16:33 Guilherme G. Piccoli
2024-05-19 18:15 ` Kees Cook
2024-05-23 7:11 ` Ard Biesheuvel
0 siblings, 2 replies; 3+ messages in thread
From: Guilherme G. Piccoli @ 2024-05-19 16:33 UTC (permalink / raw)
To: linux-efi, linux-hardening
Cc: keescook, tony.luck, ardb, kernel, kernel-dev,
Guilherme G. Piccoli
Right now efi-pstore either returns 0 (success) or -EIO; but we
do have a function to convert UEFI errors in different standard
error codes, helping to narrow down potential issues more accurately.
So, let's use this helper here.
Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
---
drivers/firmware/efi/efi-pstore.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c
index 833cbb995dd3..194fdbd600ad 100644
--- a/drivers/firmware/efi/efi-pstore.c
+++ b/drivers/firmware/efi/efi-pstore.c
@@ -136,7 +136,7 @@ static int efi_pstore_read_func(struct pstore_record *record,
&size, record->buf);
if (status != EFI_SUCCESS) {
kfree(record->buf);
- return -EIO;
+ return efi_status_to_err(status);
}
/*
@@ -181,7 +181,7 @@ static ssize_t efi_pstore_read(struct pstore_record *record)
return 0;
if (status != EFI_SUCCESS)
- return -EIO;
+ return efi_status_to_err(status);
/* skip variables that don't concern us */
if (efi_guidcmp(guid, LINUX_EFI_CRASH_GUID))
@@ -219,7 +219,7 @@ static int efi_pstore_write(struct pstore_record *record)
record->size, record->psi->buf,
true);
efivar_unlock();
- return status == EFI_SUCCESS ? 0 : -EIO;
+ return efi_status_to_err(status);
};
static int efi_pstore_erase(struct pstore_record *record)
@@ -230,7 +230,7 @@ static int efi_pstore_erase(struct pstore_record *record)
PSTORE_EFI_ATTRIBUTES, 0, NULL);
if (status != EFI_SUCCESS && status != EFI_NOT_FOUND)
- return -EIO;
+ return efi_status_to_err(status);
return 0;
}
--
2.43.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] efi: pstore: Return proper errors on UEFI failures
2024-05-19 16:33 [PATCH] efi: pstore: Return proper errors on UEFI failures Guilherme G. Piccoli
@ 2024-05-19 18:15 ` Kees Cook
2024-05-23 7:11 ` Ard Biesheuvel
1 sibling, 0 replies; 3+ messages in thread
From: Kees Cook @ 2024-05-19 18:15 UTC (permalink / raw)
To: Guilherme G. Piccoli
Cc: linux-efi, linux-hardening, tony.luck, ardb, kernel, kernel-dev
On Sun, May 19, 2024 at 01:33:53PM -0300, Guilherme G. Piccoli wrote:
> Right now efi-pstore either returns 0 (success) or -EIO; but we
> do have a function to convert UEFI errors in different standard
> error codes, helping to narrow down potential issues more accurately.
>
> So, let's use this helper here.
>
> Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
Ah yeah, good idea!
Reviewed-by: Kees Cook <keescook@chromium.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] efi: pstore: Return proper errors on UEFI failures
2024-05-19 16:33 [PATCH] efi: pstore: Return proper errors on UEFI failures Guilherme G. Piccoli
2024-05-19 18:15 ` Kees Cook
@ 2024-05-23 7:11 ` Ard Biesheuvel
1 sibling, 0 replies; 3+ messages in thread
From: Ard Biesheuvel @ 2024-05-23 7:11 UTC (permalink / raw)
To: Guilherme G. Piccoli
Cc: linux-efi, linux-hardening, keescook, tony.luck, kernel,
kernel-dev
On Sun, 19 May 2024 at 18:34, Guilherme G. Piccoli <gpiccoli@igalia.com> wrote:
>
> Right now efi-pstore either returns 0 (success) or -EIO; but we
> do have a function to convert UEFI errors in different standard
> error codes, helping to narrow down potential issues more accurately.
>
> So, let's use this helper here.
>
> Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
Queued up, thanks.
> ---
> drivers/firmware/efi/efi-pstore.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c
> index 833cbb995dd3..194fdbd600ad 100644
> --- a/drivers/firmware/efi/efi-pstore.c
> +++ b/drivers/firmware/efi/efi-pstore.c
> @@ -136,7 +136,7 @@ static int efi_pstore_read_func(struct pstore_record *record,
> &size, record->buf);
> if (status != EFI_SUCCESS) {
> kfree(record->buf);
> - return -EIO;
> + return efi_status_to_err(status);
> }
>
> /*
> @@ -181,7 +181,7 @@ static ssize_t efi_pstore_read(struct pstore_record *record)
> return 0;
>
> if (status != EFI_SUCCESS)
> - return -EIO;
> + return efi_status_to_err(status);
>
> /* skip variables that don't concern us */
> if (efi_guidcmp(guid, LINUX_EFI_CRASH_GUID))
> @@ -219,7 +219,7 @@ static int efi_pstore_write(struct pstore_record *record)
> record->size, record->psi->buf,
> true);
> efivar_unlock();
> - return status == EFI_SUCCESS ? 0 : -EIO;
> + return efi_status_to_err(status);
> };
>
> static int efi_pstore_erase(struct pstore_record *record)
> @@ -230,7 +230,7 @@ static int efi_pstore_erase(struct pstore_record *record)
> PSTORE_EFI_ATTRIBUTES, 0, NULL);
>
> if (status != EFI_SUCCESS && status != EFI_NOT_FOUND)
> - return -EIO;
> + return efi_status_to_err(status);
> return 0;
> }
>
> --
> 2.43.2
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-05-23 7:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-19 16:33 [PATCH] efi: pstore: Return proper errors on UEFI failures Guilherme G. Piccoli
2024-05-19 18:15 ` Kees Cook
2024-05-23 7:11 ` Ard Biesheuvel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox