From patchwork Tue Jun 8 18:26:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 455826 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp4029434jae; Tue, 8 Jun 2021 12:10:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJwVNNisdDgZYUsQAT39hlpUm6vj1iHyvFwjiPo5UfU+r2B1e94/1IRdBA6cA48VyrFn0n X-Received: by 2002:a17:906:c289:: with SMTP id r9mr22179575ejz.355.1623179430091; Tue, 08 Jun 2021 12:10:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623179430; cv=none; d=google.com; s=arc-20160816; b=ve+w5nmi6fw5x6RSeNnHYsVsfA0wBJnnoVMeuWhCH/XXlMmv2+Ah9nw4Ni7J7Ks8iZ x1oGEBYU/TgOjRE7x5HqjM34D997xamOgWVLCHz5AslVU2dJwa0G1mZhmCW8dsiIvOH4 QotSc2xmbYwoUvB/TmOryzPQOK+G6CEJXSoIl6r0mksKVMFFYZaOM1xZk3e+MRUdqt4n vg8ZG+zFeaReGiikJQjAV3xBXyWl5zXp7wzZ5PinOW8RvUZWHxMTK++Vl1GBC1eHndKC mb2WYGJmyJDKTifhPs481KYMGKTq/ZLB0q8D6CXgUHbHyeTAvKUFRMcrNg3ZEaNDJggJ +Zfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=To4OrJUgduCFl8Uk2JTV9HmAF4EWt6Nkzro5Z8LcaXU=; b=rxKUHSX7nX4Y+ykOpygj/5lz1sf8jS1aJ0NH+hUJUVTpIxTz4KdLxH+UCgPq73DvZd i0xo8rvLZr7vg6f4BXv4bJtETPrcMWRGCuZd6/mJhq0Bxx2zwkILIXwd59/44PR+AAsM HJLfKJxw/jcjrvj8E2/u8a+8tm6MJ6kxGD07DuV+iR4/j5i88YHIYI8oENBuV374947L Vm9AR9WgJRk2UnAJw38Lf7uYn9kwc63M6yS9McE6ZqR+fOC4pmXVpCMNk7uZlGY7P+NJ bHQxVCCBb7VDCF+HR/Vs88Sf0EJuUKKcbPsWKULWeTRhjNan/4YRBUSxmWqBru7Z6ndN VJ6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=L6sJQMTq; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fh1si452515ejc.91.2021.06.08.12.10.29; Tue, 08 Jun 2021 12:10:30 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=L6sJQMTq; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236712AbhFHTLk (ORCPT + 12 others); Tue, 8 Jun 2021 15:11:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:58010 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236348AbhFHTJE (ORCPT ); Tue, 8 Jun 2021 15:09:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 50659613AE; Tue, 8 Jun 2021 18:47:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623178075; bh=UUA0sIrWV84XDjQBHcEMWfg5LqT3cmmURY1VZbnnmZ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L6sJQMTqPF9YWvIRy1wDvdfz03V4QHMVHb/COuWLz+FAr+Z4oVT3G6x2IobZF6l2Z xtBZnkqSryNrVaE3OJpplsXXP58mva72cnyX8U7Dff6FjFSm8mJ8ejuezYjWppXtOF MJkAYvAmfyTxgpy+fXr/OQDJQzWSaLOgk49d+gHA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andy Shevchenko , Jens Wiklander , Sasha Levin Subject: [PATCH 5.12 067/161] optee: use export_uuid() to copy client UUID Date: Tue, 8 Jun 2021 20:26:37 +0200 Message-Id: <20210608175947.728559222@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210608175945.476074951@linuxfoundation.org> References: <20210608175945.476074951@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jens Wiklander [ Upstream commit 673c7aa2436bfc857b92417f3e590a297c586dde ] 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 Signed-off-by: Sasha Levin --- drivers/tee/optee/call.c | 6 ++++-- drivers/tee/optee/optee_msg.h | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) -- 2.30.2 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; };