diff mbox series

[v2,2/2] tee: optee: support session login as REE kernel

Message ID 20210519142613.7668-2-etienne.carriere@linaro.org
State New
Headers show
Series [v2,1/2] tee: define session login identifiers | expand

Commit Message

Etienne Carriere May 19, 2021, 2:26 p.m. UTC
Remove unused OPTEE_MSG_LOGIN_* IDs and rely on the ones introduced in
tee.h. Change optee core to treat invalid client IDs as public login.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>

---
Changes since v1:
- Remove ID conversion. I kept the sanitation of login ID for optee.
---
 drivers/tee/optee/core.c      | 19 ++++++++++++++++++-
 drivers/tee/optee/optee_msg.h | 10 ----------
 2 files changed, 18 insertions(+), 11 deletions(-)

-- 
2.17.1

Comments

Jens Wiklander May 20, 2021, 2:56 p.m. UTC | #1
On Wed, May 19, 2021 at 4:27 PM Etienne Carriere
<etienne.carriere@linaro.org> wrote:
>

> Remove unused OPTEE_MSG_LOGIN_* IDs and rely on the ones introduced in

> tee.h. Change optee core to treat invalid client IDs as public login.

>

> Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>

> ---

> Changes since v1:

> - Remove ID conversion. I kept the sanitation of login ID for optee.

> ---

>  drivers/tee/optee/core.c      | 19 ++++++++++++++++++-

>  drivers/tee/optee/optee_msg.h | 10 ----------

>  2 files changed, 18 insertions(+), 11 deletions(-)

>

> diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c

> index 73dbb22ba0..14f9cce5f8 100644

> --- a/drivers/tee/optee/core.c

> +++ b/drivers/tee/optee/core.c

> @@ -349,6 +349,23 @@ static int optee_close_session(struct udevice *dev, u32 session)

>         return 0;

>  }

>

> +static u32 optee_login_id(u32 login_id)

> +{

> +       /* Treat invalid IDs as public login */

> +       switch (login_id) {

> +       case TEE_LOGIN_USER:

> +       case TEE_LOGIN_GROUP:

> +       case TEE_LOGIN_APPLICATION:

> +       case TEE_LOGIN_APPLICATION_USER:

> +       case TEE_LOGIN_APPLICATION_GROUP:

> +       case TEE_LOGIN_REE_KERNEL:

> +               return login_id;

> +       case TEE_LOGIN_PUBLIC:

> +       default:

> +               return TEE_LOGIN_PUBLIC;

> +       }

> +}

> +


What is the point with translating an unrecognized value into TEE_LOGIN_PUBLIC?
We could just as well let OP-TEE decide what to do with that.

Cheers,
Jens
Etienne Carriere May 21, 2021, 1:13 p.m. UTC | #2
On Thu, 20 May 2021 at 16:56, Jens Wiklander <jens.wiklander@linaro.org> wrote:
>

> On Wed, May 19, 2021 at 4:27 PM Etienne Carriere

> <etienne.carriere@linaro.org> wrote:

> >

> > Remove unused OPTEE_MSG_LOGIN_* IDs and rely on the ones introduced in

> > tee.h. Change optee core to treat invalid client IDs as public login.

> >

> > Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>

> > ---

> > Changes since v1:

> > - Remove ID conversion. I kept the sanitation of login ID for optee.

> > ---

> >  drivers/tee/optee/core.c      | 19 ++++++++++++++++++-

> >  drivers/tee/optee/optee_msg.h | 10 ----------

> >  2 files changed, 18 insertions(+), 11 deletions(-)

> >

> > diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c

> > index 73dbb22ba0..14f9cce5f8 100644

> > --- a/drivers/tee/optee/core.c

> > +++ b/drivers/tee/optee/core.c

> > @@ -349,6 +349,23 @@ static int optee_close_session(struct udevice *dev, u32 session)

> >         return 0;

> >  }

> >

> > +static u32 optee_login_id(u32 login_id)

> > +{

> > +       /* Treat invalid IDs as public login */

> > +       switch (login_id) {

> > +       case TEE_LOGIN_USER:

> > +       case TEE_LOGIN_GROUP:

> > +       case TEE_LOGIN_APPLICATION:

> > +       case TEE_LOGIN_APPLICATION_USER:

> > +       case TEE_LOGIN_APPLICATION_GROUP:

> > +       case TEE_LOGIN_REE_KERNEL:

> > +               return login_id;

> > +       case TEE_LOGIN_PUBLIC:

> > +       default:

> > +               return TEE_LOGIN_PUBLIC;

> > +       }

> > +}

> > +

>

> What is the point with translating an unrecognized value into TEE_LOGIN_PUBLIC?

> We could just as well let OP-TEE decide what to do with that.


Yes, we could simply pass the identifier, whatever it is.
i'll remove this part in the v3.

Cheers,
Etienne

>

> Cheers,

> Jens
diff mbox series

Patch

diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
index 73dbb22ba0..14f9cce5f8 100644
--- a/drivers/tee/optee/core.c
+++ b/drivers/tee/optee/core.c
@@ -349,6 +349,23 @@  static int optee_close_session(struct udevice *dev, u32 session)
 	return 0;
 }
 
+static u32 optee_login_id(u32 login_id)
+{
+	/* Treat invalid IDs as public login */
+	switch (login_id) {
+	case TEE_LOGIN_USER:
+	case TEE_LOGIN_GROUP:
+	case TEE_LOGIN_APPLICATION:
+	case TEE_LOGIN_APPLICATION_USER:
+	case TEE_LOGIN_APPLICATION_GROUP:
+	case TEE_LOGIN_REE_KERNEL:
+		return login_id;
+	case TEE_LOGIN_PUBLIC:
+	default:
+		return TEE_LOGIN_PUBLIC;
+	}
+}
+
 static int optee_open_session(struct udevice *dev,
 			      struct tee_open_session_arg *arg,
 			      uint num_params, struct tee_param *params)
@@ -372,7 +389,7 @@  static int optee_open_session(struct udevice *dev,
 				  OPTEE_MSG_ATTR_META;
 	memcpy(&msg_arg->params[0].u.value, arg->uuid, sizeof(arg->uuid));
 	memcpy(&msg_arg->params[1].u.value, arg->uuid, sizeof(arg->clnt_uuid));
-	msg_arg->params[1].u.value.c = arg->clnt_login;
+	msg_arg->params[1].u.value.c = optee_login_id(arg->clnt_login);
 
 	rc = to_msg_param(msg_arg->params + 2, num_params, params);
 	if (rc)
diff --git a/drivers/tee/optee/optee_msg.h b/drivers/tee/optee/optee_msg.h
index 8d40ce60c2..9490592a8e 100644
--- a/drivers/tee/optee/optee_msg.h
+++ b/drivers/tee/optee/optee_msg.h
@@ -86,16 +86,6 @@ 
 #define OPTEE_MSG_ATTR_CACHE_MASK		GENMASK(2, 0)
 #define OPTEE_MSG_ATTR_CACHE_PREDEFINED		0
 
-/*
- * Same values as TEE_LOGIN_* from TEE Internal API
- */
-#define OPTEE_MSG_LOGIN_PUBLIC			0x00000000
-#define OPTEE_MSG_LOGIN_USER			0x00000001
-#define OPTEE_MSG_LOGIN_GROUP			0x00000002
-#define OPTEE_MSG_LOGIN_APPLICATION		0x00000004
-#define OPTEE_MSG_LOGIN_APPLICATION_USER	0x00000005
-#define OPTEE_MSG_LOGIN_APPLICATION_GROUP	0x00000006
-
 /*
  * Page size used in non-contiguous buffer entries
  */