All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] efi_loader: Check for the native OP-TEE result on mm_communicate calls
@ 2020-07-22  7:32 Ilias Apalodimas
  2020-07-22 10:21 ` Heinrich Schuchardt
  0 siblings, 1 reply; 2+ messages in thread
From: Ilias Apalodimas @ 2020-07-22  7:32 UTC (permalink / raw)
  To: u-boot

Currently we only check for the return value of tee_invoke_func().
Although OP-TEE and StMM will correctly set param[1].u.value.a and we'll
eventually return an error, the correct thing to do is check for the
OP_TEE return code as well.
So let's check for that and move tee_shm_free() and tee_close_session()
before exiting with an error to make sure we always clear the registered
memory.

Fixes: f042e47e8fb43 ("efi_loader: Implement EFI variable handling via OP-TEE")
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
 lib/efi_loader/efi_variable_tee.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c
index c0423489388a..346f4c786f28 100644
--- a/lib/efi_loader/efi_variable_tee.c
+++ b/lib/efi_loader/efi_variable_tee.c
@@ -100,10 +100,10 @@ static efi_status_t optee_mm_communicate(void *comm_buf, ulong dsize)
 	param[1].attr = TEE_PARAM_ATTR_TYPE_VALUE_OUTPUT;
 
 	rc = tee_invoke_func(conn.tee, &arg, 2, param);
-	if (rc)
-		return EFI_INVALID_PARAMETER;
 	tee_shm_free(shm);
 	tee_close_session(conn.tee, conn.session);
+	if (rc || arg.ret != TEE_SUCCESS)
+		return EFI_INVALID_PARAMETER;
 
 	switch (param[1].u.value.a) {
 	case ARM_SMC_MM_RET_SUCCESS:
-- 
2.28.0.rc1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] efi_loader: Check for the native OP-TEE result on mm_communicate calls
  2020-07-22  7:32 [PATCH] efi_loader: Check for the native OP-TEE result on mm_communicate calls Ilias Apalodimas
@ 2020-07-22 10:21 ` Heinrich Schuchardt
  0 siblings, 0 replies; 2+ messages in thread
From: Heinrich Schuchardt @ 2020-07-22 10:21 UTC (permalink / raw)
  To: u-boot

On 22.07.20 09:32, Ilias Apalodimas wrote:
> Currently we only check for the return value of tee_invoke_func().
> Although OP-TEE and StMM will correctly set param[1].u.value.a and we'll
> eventually return an error, the correct thing to do is check for the
> OP_TEE return code as well.
> So let's check for that and move tee_shm_free() and tee_close_session()
> before exiting with an error to make sure we always clear the registered
> memory.
>
> Fixes: f042e47e8fb43 ("efi_loader: Implement EFI variable handling via OP-TEE")
> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>> ---
>  lib/efi_loader/efi_variable_tee.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c
> index c0423489388a..346f4c786f28 100644
> --- a/lib/efi_loader/efi_variable_tee.c
> +++ b/lib/efi_loader/efi_variable_tee.c
> @@ -100,10 +100,10 @@ static efi_status_t optee_mm_communicate(void *comm_buf, ulong dsize)
>  	param[1].attr = TEE_PARAM_ATTR_TYPE_VALUE_OUTPUT;
>
>  	rc = tee_invoke_func(conn.tee, &arg, 2, param);
> -	if (rc)
> -		return EFI_INVALID_PARAMETER;
>  	tee_shm_free(shm);
>  	tee_close_session(conn.tee, conn.session);
> +	if (rc || arg.ret != TEE_SUCCESS)
> +		return EFI_INVALID_PARAMETER;

I will use EFI_DEVICE_ERROR here when merging as this indicates an
internal problem in contrast to a problem caused by the caller of the
UEFI API.

Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>
>  	switch (param[1].u.value.a) {
>  	case ARM_SMC_MM_RET_SUCCESS:
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-22 10:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-22  7:32 [PATCH] efi_loader: Check for the native OP-TEE result on mm_communicate calls Ilias Apalodimas
2020-07-22 10:21 ` Heinrich Schuchardt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.