From patchwork Tue Apr 20 08:25:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Wiklander X-Patchwork-Id: 424551 Delivered-To: patches@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp165849jao; Tue, 20 Apr 2021 01:26:14 -0700 (PDT) X-Received: by 2002:a05:6512:90c:: with SMTP id e12mr5527716lft.449.1618907173860; Tue, 20 Apr 2021 01:26:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618907173; cv=none; d=google.com; s=arc-20160816; b=JqNmmMcy7vtCiRFhi+vOqWYWKelvGMPnhPlhTCn5U9Hz3PFQVpksigtGlOLHVzrQE6 gl2K6cggNOVDwskpfse/25cn37PuqdRepX+1kadBVqGL71h1eGYecTQhcE0Uq0dyf5Ft ZUoRD058+yvJt109OYkU3tpae1599aItZ73zup57EojlfxaUEAyMBKZrRQmIHtckW5YN mQA+TCITTVV93iyXHuZblXO2giE7BKaeGbFcbzmwDRw9x+uHzSeLZ2+BKt/3J0XIAuL/ Yy70QBzeKDW6LSIeLDFsxOqo09F/DVwSuMgiZix8FRTgo0xKk/Q1FzYhh4aasQt5iHPj PAaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=tDRPN4ck5c/LMQMDRR6RqCECkMdMxHcVqcxleCtfwRg=; b=Nyt4NU7HUX/XtOnCgkFouLopkenI5EtwIAWgF2pbxIwf+mBKfnmZSGTbPLo343JJWe 1Ub8fjJBBuYtJw+J21p6XfH7QDqbLxoUWLPV4nAmAoxvz52/JhfhUDZsJgKbggIXwpVV NxmI47+HZva96DmGElpZISKU8iDX6hsPakbVqON/hmtNudbJ2jvINM8qDKQm+AVIGUZl Y7Odi0bObcDE+gOIruub+LcfWlCgSqsePAKyUU7BNquKBBElsNBwLZ89ohpfS2HcX/0x ZetXloJQlAyFkHxrJFIoFV7f4srriqwrxzgXGh5Wm+UBupSbyth48boFLqag392SS+Qs kTNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q05QfvFM; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id d1sor3824010lfi.132.2021.04.20.01.26.13 for (Google Transport Security); Tue, 20 Apr 2021 01:26:13 -0700 (PDT) Received-SPF: pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q05QfvFM; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tDRPN4ck5c/LMQMDRR6RqCECkMdMxHcVqcxleCtfwRg=; b=Q05QfvFMXF2/pyyy2Ue7j7Rc8U3HIouXGj15VCi8LVLnFj7hU2w1sPbRZH58bzRNEK 8Sqx3LRHhCpFJXkfn+BSOC4sNxTWQ7K8K5gp0OInTayRnSNs56ULa2/uNLCFnQ5gGLJf NIcveJwn6ChhigWtJnRZxw/kUgI/0poZt03hURnEwOhB3YvrUphi+lizrYA5Ko8diKTc KzaKXmDmaC3cKR4mpslWJ2E35rK62VGhgJaCR/gFAHtEIZmbPt+YXZI1Uz7pmvITs6Zn cZBTDgTB6jcUJj3nKUAF/c/ECEx4g/ShjlQFc3wms52Pv8hG2Zu/Y9zZBHp6875ys6rZ 9yNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tDRPN4ck5c/LMQMDRR6RqCECkMdMxHcVqcxleCtfwRg=; b=nN3F1RjwByMSsYolCMcJkzcy5imx6Mx4vmLIP6MUHiGiVqSDL+TWZAKTnyCW1yB+XS oViTKoKP0x/7XpL57rvEtT0KPrBULzgiA4qC2g/y+QkUquI+wWeZp/1cJwmrwNFGNfYz +BNGMQzwAjqNt8edgD97naVi4HrCBzA/BE9QU9ThicuN7fyHzo7KwUeK80GEvQEc/X6e W6zu3PYPR+D+LjQU79C3wyoVxqhT8ZL5QTHDUOJT/6lGJUjs8P2Afjxc+Evqr5QuE0sD gGdHfsA8+VbAV8zIqkh60wEA3CAzK10iBWXu6/opbgzRKGwiQu2+upHnXBj4knx6vq8M xRZg== X-Gm-Message-State: AOAM532XaOZGeOKbIDtuqCxXCvvcadYLFb7QfXpDqxdfZ5QhTYgDR6Tj rT2jusTfpm06BopLH5tTEGmO0wGuMpj+1FTH X-Google-Smtp-Source: ABdhPJx0E2W7V/TpdQDr8e2kPEtL/EFp3oKQI3IdvmVr2VQpru3ZXohnLT2Enf37tSSFjr6tQqR3NQ== X-Received: by 2002:ac2:4aca:: with SMTP id m10mr11297426lfp.255.1618907173384; Tue, 20 Apr 2021 01:26:13 -0700 (PDT) Return-Path: Received: from jade.urgonet (h-85-3.A175.priv.bahnhof.se. [79.136.85.3]) by smtp.gmail.com with ESMTPSA id o16sm2077751lfu.228.2021.04.20.01.26.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 01:26:12 -0700 (PDT) From: Jens Wiklander To: linux-kernel@vger.kernel.org, op-tee@lists.trustedfirmware.org Cc: Andy Shevchenko , =?utf-8?q?Vesa_J?= =?utf-8?b?w6TDpHNrZWzDpGluZW4=?= , Jens Wiklander Subject: [PATCH] optee: use export_uuid() to copy client UUID Date: Tue, 20 Apr 2021 10:25:47 +0200 Message-Id: <20210420082547.3542261-1-jens.wiklander@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Prior to this patch optee_open_session() was making assumptions about the internal format of uuid_t by casting a memory location in a parameter struct to uuid_t *. Fix this using export_uuid() to get a well defined binary representation and also add an octets field in struct optee_msg_param in order to avoid casting. Fixes: c5b4312bea5d ("tee: optee: Add support for session login client UUID generation") Suggested-by: Andy Shevchenko Signed-off-by: Jens Wiklander --- drivers/tee/optee/call.c | 6 ++++-- drivers/tee/optee/optee_msg.h | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) -- 2.25.1 diff --git a/drivers/tee/optee/call.c b/drivers/tee/optee/call.c index 7a77e375b503..6b52f0c526ba 100644 --- a/drivers/tee/optee/call.c +++ b/drivers/tee/optee/call.c @@ -216,6 +216,7 @@ int optee_open_session(struct tee_context *ctx, struct optee_msg_arg *msg_arg; phys_addr_t msg_parg; struct optee_session *sess = NULL; + uuid_t client_uuid; /* +2 for the meta parameters added below */ shm = get_msg_arg(ctx, arg->num_params + 2, &msg_arg, &msg_parg); @@ -236,10 +237,11 @@ int optee_open_session(struct tee_context *ctx, memcpy(&msg_arg->params[0].u.value, arg->uuid, sizeof(arg->uuid)); msg_arg->params[1].u.value.c = arg->clnt_login; - rc = tee_session_calc_client_uuid((uuid_t *)&msg_arg->params[1].u.value, - arg->clnt_login, arg->clnt_uuid); + rc = tee_session_calc_client_uuid(&client_uuid, arg->clnt_login, + arg->clnt_uuid); if (rc) goto out; + export_uuid(msg_arg->params[1].u.octets, &client_uuid); rc = optee_to_msg_param(msg_arg->params + 2, arg->num_params, param); if (rc) diff --git a/drivers/tee/optee/optee_msg.h b/drivers/tee/optee/optee_msg.h index 81ff593ac4ec..e3d72d09c484 100644 --- a/drivers/tee/optee/optee_msg.h +++ b/drivers/tee/optee/optee_msg.h @@ -9,7 +9,7 @@ #include /* - * This file defines the OP-TEE message protocol used to communicate + * This file defines the OP-TEE message protocol (ABI) used to communicate * with an instance of OP-TEE running in secure world. * * This file is divided into two sections. @@ -144,9 +144,10 @@ struct optee_msg_param_value { * @tmem: parameter by temporary memory reference * @rmem: parameter by registered memory reference * @value: parameter by opaque value + * @octets: parameter by octet string * * @attr & OPTEE_MSG_ATTR_TYPE_MASK indicates if tmem, rmem or value is used in - * the union. OPTEE_MSG_ATTR_TYPE_VALUE_* indicates value, + * the union. OPTEE_MSG_ATTR_TYPE_VALUE_* indicates value or octets, * OPTEE_MSG_ATTR_TYPE_TMEM_* indicates @tmem and * OPTEE_MSG_ATTR_TYPE_RMEM_* indicates @rmem, * OPTEE_MSG_ATTR_TYPE_NONE indicates that none of the members are used. @@ -157,6 +158,7 @@ struct optee_msg_param { struct optee_msg_param_tmem tmem; struct optee_msg_param_rmem rmem; struct optee_msg_param_value value; + u8 octets[24]; } u; };