All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen/arm: optee: allow plain TMEM buffers with NULL address
@ 2020-05-18  1:53 Volodymyr Babchuk
  2020-06-06 15:19 ` Julien Grall
  0 siblings, 1 reply; 12+ messages in thread
From: Volodymyr Babchuk @ 2020-05-18  1:53 UTC (permalink / raw)
  To: sstabellini@kernel.org, julien@xen.org,
	xen-devel@lists.xenproject.org

Trusted Applications use popular approach to determine required size
of buffer: client provides a memory reference with the NULL pointer to
a buffer. This is so called "Null memory reference".  TA updates the
reference with the required size and returns it back to client. Then
client allocates buffer of needed size and repeats the operation.

This behavior is described in TEE Client API Specification, paragraph
3.2.5. Memory References.

OP-TEE represents this null memory reference as a TMEM parameter with
buf_ptr == NULL. This is the only case when we should allow TMEM
buffer without the OPTEE_MSG_ATTR_NONCONTIG flag.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
---
 xen/arch/arm/tee/optee.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/xen/arch/arm/tee/optee.c b/xen/arch/arm/tee/optee.c
index af19fc31f8..fb7d491b25 100644
--- a/xen/arch/arm/tee/optee.c
+++ b/xen/arch/arm/tee/optee.c
@@ -865,9 +865,12 @@ static int translate_params(struct optee_domain
*ctx,
             }
             else
             {
-                gdprintk(XENLOG_WARNING, "Guest tries to use old tmem
arg\n");
-                ret = -EINVAL;
-                goto out;
+                if ( call->xen_arg->params[i].u.tmem.buf_ptr )
+                {
+                    gdprintk(XENLOG_WARNING, "Guest tries to use old
tmem arg\n");
+                    ret = -EINVAL;
+                    goto out;
+                }
             }
             break;
         case OPTEE_MSG_ATTR_TYPE_NONE:

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

end of thread, other threads:[~2020-06-19 18:04 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-18  1:53 [PATCH] xen/arm: optee: allow plain TMEM buffers with NULL address Volodymyr Babchuk
2020-06-06 15:19 ` Julien Grall
2020-06-18 22:26   ` Stefano Stabellini
2020-06-18 23:32     ` Volodymyr Babchuk
2020-06-19  8:47     ` Paul Durrant
2020-06-18 23:29   ` Volodymyr Babchuk
2020-06-19  9:23     ` Julien Grall
2020-06-19  9:52       ` Volodymyr Babchuk
2020-06-19 10:25         ` Julien Grall
2020-06-19 17:15           ` Stefano Stabellini
2020-06-19 17:40             ` Julien Grall
2020-06-19 18:04               ` Stefano Stabellini

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.