2023-04-20 08:18:17

by Etienne Carriere

[permalink] [raw]
Subject: [PATCH] optee: fix uninited async notif value

Fixes an uninitialized variable in irq_handler() that could lead to
unpredictable behavior in case OP-TEE fails to handle SMC function ID
OPTEE_SMC_GET_ASYNC_NOTIF_VALUE. This change ensures that in that case
get_async_notif_value() properly reports there are no notification
event.

Reported-by: kernel test robot <[email protected]>
Link: https://lore.kernel.org/r/[email protected]/
Reported-by: Dan Carpenter <[email protected]>
Link: https://lore.kernel.org/all/[email protected]/
Fixes: 6749e69c4dad ("optee: add asynchronous notifications")
Signed-off-by: Etienne Carriere <[email protected]>
---
drivers/tee/optee/smc_abi.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/tee/optee/smc_abi.c b/drivers/tee/optee/smc_abi.c
index de7ac9a46354..6d3705770755 100644
--- a/drivers/tee/optee/smc_abi.c
+++ b/drivers/tee/optee/smc_abi.c
@@ -1001,8 +1001,10 @@ static u32 get_async_notif_value(optee_invoke_fn *invoke_fn, bool *value_valid,

invoke_fn(OPTEE_SMC_GET_ASYNC_NOTIF_VALUE, 0, 0, 0, 0, 0, 0, 0, &res);

- if (res.a0)
+ if (res.a0) {
+ *value_valid = false;
return 0;
+ }
*value_valid = (res.a2 & OPTEE_SMC_ASYNC_NOTIF_VALUE_VALID);
*value_pending = (res.a2 & OPTEE_SMC_ASYNC_NOTIF_VALUE_PENDING);
return res.a1;
--
2.25.1


2023-04-20 09:09:52

by Sumit Garg

[permalink] [raw]
Subject: Re: [PATCH] optee: fix uninited async notif value

On Thu, 20 Apr 2023 at 13:43, Etienne Carriere
<[email protected]> wrote:
>
> Fixes an uninitialized variable in irq_handler() that could lead to
> unpredictable behavior in case OP-TEE fails to handle SMC function ID
> OPTEE_SMC_GET_ASYNC_NOTIF_VALUE. This change ensures that in that case
> get_async_notif_value() properly reports there are no notification
> event.
>
> Reported-by: kernel test robot <[email protected]>
> Link: https://lore.kernel.org/r/[email protected]/
> Reported-by: Dan Carpenter <[email protected]>
> Link: https://lore.kernel.org/all/[email protected]/
> Fixes: 6749e69c4dad ("optee: add asynchronous notifications")
> Signed-off-by: Etienne Carriere <[email protected]>
> ---
> drivers/tee/optee/smc_abi.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>

Reviewed-by: Sumit Garg <[email protected]>

-Sumit

> diff --git a/drivers/tee/optee/smc_abi.c b/drivers/tee/optee/smc_abi.c
> index de7ac9a46354..6d3705770755 100644
> --- a/drivers/tee/optee/smc_abi.c
> +++ b/drivers/tee/optee/smc_abi.c
> @@ -1001,8 +1001,10 @@ static u32 get_async_notif_value(optee_invoke_fn *invoke_fn, bool *value_valid,
>
> invoke_fn(OPTEE_SMC_GET_ASYNC_NOTIF_VALUE, 0, 0, 0, 0, 0, 0, 0, &res);
>
> - if (res.a0)
> + if (res.a0) {
> + *value_valid = false;
> return 0;
> + }
> *value_valid = (res.a2 & OPTEE_SMC_ASYNC_NOTIF_VALUE_VALID);
> *value_pending = (res.a2 & OPTEE_SMC_ASYNC_NOTIF_VALUE_PENDING);
> return res.a1;
> --
> 2.25.1
>