2023-01-31 06:40:26

by Andrew Donnellan

[permalink] [raw]
Subject: [PATCH v5 03/25] powerpc/secvar: Fix incorrect return in secvar_sysfs_load()

From: Russell Currey <[email protected]>

secvar_ops->get_next() returns -ENOENT when there are no more variables
to return, which is expected behaviour.

Fix this by returning 0 if get_next() returns -ENOENT.

This fixes an issue introduced in commit bd5d9c743d38 ("powerpc: expose
secure variables to userspace via sysfs"), but the return code of
secvar_sysfs_load() was never checked so this issue never mattered.

Signed-off-by: Russell Currey <[email protected]>
Signed-off-by: Andrew Donnellan <[email protected]>

---

v5: New patch
---
arch/powerpc/kernel/secvar-sysfs.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/secvar-sysfs.c b/arch/powerpc/kernel/secvar-sysfs.c
index 1ee4640a2641..7fa5f8ed9542 100644
--- a/arch/powerpc/kernel/secvar-sysfs.c
+++ b/arch/powerpc/kernel/secvar-sysfs.c
@@ -179,8 +179,10 @@ static int secvar_sysfs_load(void)
rc = secvar_ops->get_next(name, &namesize, NAME_MAX_SIZE);
if (rc) {
if (rc != -ENOENT)
- pr_err("error getting secvar from firmware %d\n",
- rc);
+ pr_err("error getting secvar from firmware %d\n", rc);
+ else
+ rc = 0;
+
break;
}

--
2.39.1



2023-01-31 15:21:07

by Stefan Berger

[permalink] [raw]
Subject: Re: [PATCH v5 03/25] powerpc/secvar: Fix incorrect return in secvar_sysfs_load()



On 1/31/23 01:39, Andrew Donnellan wrote:
> From: Russell Currey <[email protected]>
>
> secvar_ops->get_next() returns -ENOENT when there are no more variables
> to return, which is expected behaviour.
>
> Fix this by returning 0 if get_next() returns -ENOENT.
>
> This fixes an issue introduced in commit bd5d9c743d38 ("powerpc: expose
> secure variables to userspace via sysfs"), but the return code of
> secvar_sysfs_load() was never checked so this issue never mattered.
>
> Signed-off-by: Russell Currey <[email protected]>
> Signed-off-by: Andrew Donnellan <[email protected]>
>
> ---
>
> v5: New patch
> ---
> arch/powerpc/kernel/secvar-sysfs.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/kernel/secvar-sysfs.c b/arch/powerpc/kernel/secvar-sysfs.c
> index 1ee4640a2641..7fa5f8ed9542 100644
> --- a/arch/powerpc/kernel/secvar-sysfs.c
> +++ b/arch/powerpc/kernel/secvar-sysfs.c
> @@ -179,8 +179,10 @@ static int secvar_sysfs_load(void)
> rc = secvar_ops->get_next(name, &namesize, NAME_MAX_SIZE);
> if (rc) {
> if (rc != -ENOENT)
> - pr_err("error getting secvar from firmware %d\n",
> - rc);
> + pr_err("error getting secvar from firmware %d\n", rc);
> + else
> + rc = 0;
> +
> break;
> }
>

Reviewed-by: Stefan Berger <[email protected]>