linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Vesa Jääskeläinen" <vesa.jaaskelainen@vaisala.com>
To: op-tee@lists.trustedfirmware.org,
	Jens Wiklander <jens.wiklander@linaro.org>
Cc: "Rijo Thomas" <Rijo-john.Thomas@amd.com>,
	"Herbert Xu" <herbert@gondor.apana.org.au>,
	"Dan Carpenter" <dan.carpenter@oracle.com>,
	"Devaraj Rangasamy" <Devaraj.Rangasamy@amd.com>,
	"Hongbo Yao" <yaohongbo@huawei.com>,
	"Colin Ian King" <colin.king@canonical.com>,
	linux-kernel@vger.kernel.org,
	"Vesa Jääskeläinen" <vesa.jaaskelainen@vaisala.com>
Subject: [PATCH 3/3] [RFC] tee: add support for app id for client UUID generation
Date: Thu, 23 Apr 2020 18:17:01 +0300	[thread overview]
Message-ID: <20200423151701.111231-4-vesa.jaaskelainen@vaisala.com> (raw)
In-Reply-To: <20200423151701.111231-1-vesa.jaaskelainen@vaisala.com>

Linux kernel does not provide common contex for application identifier,
instead different security frameworks provide own means to define
application identifier for running process. Code includes place holder for
such solutions but is left for later implementation.

Open questions:

1. App ID source

How to specify what source is used for app id?

Does it need to be protected on runtime?
- Should this be Kconfig setting?
- Cnfigure once during runtime thru sysfs or so?
- Configure from device tree?

2. Formatting for App ID

Should there be common format? Or common keyword id?

3. How to handle custom App ID sources

Android has own App ID so does Tizen.

Should there be place holder for this where to make local patch?

Signed-off-by: Vesa Jääskeläinen <vesa.jaaskelainen@vaisala.com>
---
 drivers/tee/tee_core.c | 45 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c
index 872272bf9dec..df03bd0071da 100644
--- a/drivers/tee/tee_core.c
+++ b/drivers/tee/tee_core.c
@@ -125,6 +125,15 @@ static int tee_release(struct inode *inode, struct file *filp)
 	return 0;
 }
 
+static const char *tee_session_get_application_id(void)
+{
+	return NULL;
+}
+
+static void tee_session_free_application_id(const char *app_id)
+{
+}
+
 /**
  * uuid_v5() - Calculate UUIDv5
  * @uuid: Resulting UUID
@@ -217,6 +226,14 @@ int tee_session_calc_client_uuid(uuid_t *uuid, u32 connection_method,
 	 * For TEEC_LOGIN_GROUP:
 	 * gid=<gid>
 	 *
+	 * For TEEC_LOGIN_APPLICATION:
+	 * app=<application id>
+	 *
+	 * For TEEC_LOGIN_USER_APPLICATION:
+	 * uid=<uid>:app=<application id>
+	 *
+	 * For TEEC_LOGIN_GROUP_APPLICATION:
+	 * gid=<gid>:app=<application id>
 	 */
 
 	name = kzalloc(TEE_UUID_NS_NAME_SIZE, GFP_KERNEL);
@@ -240,6 +257,34 @@ int tee_session_calc_client_uuid(uuid_t *uuid, u32 connection_method,
 		scnprintf(name, TEE_UUID_NS_NAME_SIZE, "gid=%x", grp.val);
 		break;
 
+	case TEE_IOCTL_LOGIN_APPLICATION:
+		application_id = tee_session_get_application_id();
+		scnprintf(name, TEE_UUID_NS_NAME_SIZE, "app=%s",
+			  application_id);
+		tee_session_free_application_id(application_id);
+		break;
+
+	case TEE_IOCTL_LOGIN_USER_APPLICATION:
+		application_id = tee_session_get_application_id();
+		scnprintf(name, TEE_UUID_NS_NAME_SIZE, "uid=%x:app=%s",
+			  current_euid().val, application_id);
+		tee_session_free_application_id(application_id);
+		break;
+
+	case TEE_IOCTL_LOGIN_GROUP_APPLICATION:
+		memcpy(&ns_grp, connection_data, sizeof(gid_t));
+		grp = make_kgid(current_user_ns(), ns_grp);
+		if (!gid_valid(grp) || !in_egroup_p(grp)) {
+			rc = -EPERM;
+			goto out;
+		}
+
+		application_id = tee_session_get_application_id();
+		scnprintf(name, TEE_UUID_NS_NAME_SIZE, "gid=%x:app=%s",
+			  grp.val, application_id);
+		tee_session_free_application_id(application_id);
+		break;
+
 	default:
 		rc = -EINVAL;
 		goto out;
-- 
2.17.1


      parent reply	other threads:[~2020-04-23 15:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-23 15:16 [PATCH 0/3] tee: add support for session's client UUID generation Vesa Jääskeläinen
2020-04-23 15:16 ` [PATCH 1/3] " Vesa Jääskeläinen
2020-04-23 17:35   ` Dan Carpenter
2020-04-25  6:16     ` Vesa Jääskeläinen
2020-04-25  9:24       ` Dan Carpenter
2020-04-23 15:17 ` [PATCH 2/3] tee: optee: Add support for session login " Vesa Jääskeläinen
2020-04-23 15:17 ` Vesa Jääskeläinen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200423151701.111231-4-vesa.jaaskelainen@vaisala.com \
    --to=vesa.jaaskelainen@vaisala.com \
    --cc=Devaraj.Rangasamy@amd.com \
    --cc=Rijo-john.Thomas@amd.com \
    --cc=colin.king@canonical.com \
    --cc=dan.carpenter@oracle.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=jens.wiklander@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=op-tee@lists.trustedfirmware.org \
    --cc=yaohongbo@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).