Skip to content

Commit 104edb9

Browse files
b49020jenswi-linaro
authored andcommitted
tee: add private login method for kernel clients
There are use-cases where user-space shouldn't be allowed to communicate directly with a TEE device which is dedicated to provide a specific service for a kernel client. So add a private login method for kernel clients and disallow user-space to open-session using GP implementation defined login method range: (0x80000000 - 0xBFFFFFFF). Reviewed-by: Jerome Forissier <[email protected]> Signed-off-by: Sumit Garg <[email protected]> Signed-off-by: Jens Wiklander <[email protected]>
1 parent 2a6ba3f commit 104edb9

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

drivers/tee/tee_core.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,13 @@ static int tee_ioctl_open_session(struct tee_context *ctx,
333333
goto out;
334334
}
335335

336+
if (arg.clnt_login >= TEE_IOCTL_LOGIN_REE_KERNEL_MIN &&
337+
arg.clnt_login <= TEE_IOCTL_LOGIN_REE_KERNEL_MAX) {
338+
pr_debug("login method not allowed for user-space client\n");
339+
rc = -EPERM;
340+
goto out;
341+
}
342+
336343
rc = ctx->teedev->desc->ops->open_session(ctx, &arg, params);
337344
if (rc)
338345
goto out;

include/uapi/linux/tee.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,15 @@ struct tee_ioctl_buf_data {
173173
#define TEE_IOCTL_LOGIN_APPLICATION 4
174174
#define TEE_IOCTL_LOGIN_USER_APPLICATION 5
175175
#define TEE_IOCTL_LOGIN_GROUP_APPLICATION 6
176+
/*
177+
* Disallow user-space to use GP implementation specific login
178+
* method range (0x80000000 - 0xBFFFFFFF). This range is rather
179+
* being reserved for REE kernel clients or TEE implementation.
180+
*/
181+
#define TEE_IOCTL_LOGIN_REE_KERNEL_MIN 0x80000000
182+
#define TEE_IOCTL_LOGIN_REE_KERNEL_MAX 0xBFFFFFFF
183+
/* Private login method for REE kernel clients */
184+
#define TEE_IOCTL_LOGIN_REE_KERNEL 0x80000000
176185

177186
/**
178187
* struct tee_ioctl_param - parameter

0 commit comments

Comments
 (0)