Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp8458027rwr; Thu, 11 May 2023 01:16:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6A1+Y3nv4gGwTbREOOGaOgWhA1xM3T4nY5WmEIsy3NRqNHBW6eZcCq8R/LAMJhiEVaIWsn X-Received: by 2002:a05:6a00:1151:b0:644:ad29:fd5b with SMTP id b17-20020a056a00115100b00644ad29fd5bmr17973216pfm.7.1683792991900; Thu, 11 May 2023 01:16:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683792991; cv=none; d=google.com; s=arc-20160816; b=beftyK9OGQdo0ZpUBSoY+TVRwFuflXLWvTTyFjbncExEbspe5EGY44pZ774c4MW37W S3+PJnuPfWohwFdWnGlhkRuL/MJCDg+wBQuCXOORJd8mO5bwcRlyI6OYNV5/19ODMO5n wJ+pBuEzsOfScE3jHEZv+LWDKzRaC9hTKoHWQRuD7raTGHqROgqiTnI765gRf1SflWm1 R7oqQXtaaSezvebJlyLlJEDLPkpxK49wZarJVOaXE6V5OrjFZNY0toLVJcdJHxd6TFf7 vxBT24t0+WJVqoK8H/wWYTnhTWZauCCIBXseKkl6pnKDZA4Z9sepgNofxEwxwFzqdXfl snEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=8J5AyuQb7KXDhIq7T1eUiZkECmH3AgrEkNzwG7/4Y1k=; b=NcnViHO+4aO6ePQkb13L0a7pIR4gXSuWqLfMpG7Pqin6M9/zemkELsTexJH33tmw4A KgkMUAUZYrlX3W0uasuKE5YtzwN1LH6C8/0qb1ZduMv42np6kDBUOKy9mVUqKOhhEyIS 7yy7fST9f0L7o0IJ9oFyv5W4lkdGyMhPzo/XdnHrP88dLUnvOnwjCOd3asHghxb5s5qW is7lC403k8dcZf2kNul7Hoh7846Py/kUifRMxswVjwgu0kFyk/D10KntTvQYWSmjTCNh /p/VeEP+mgCT2bSE/8GaKYN11/zfAsJ0IGcMZTylqGLGldlEhEB6PezjHqCh524IwjIg dVRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KgCLnWvp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r7-20020aa79887000000b00635ebd8854esi7197321pfl.173.2023.05.11.01.16.19; Thu, 11 May 2023 01:16:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KgCLnWvp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233631AbjEKIPK (ORCPT + 99 others); Thu, 11 May 2023 04:15:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233461AbjEKIPH (ORCPT ); Thu, 11 May 2023 04:15:07 -0400 Received: from mail-vk1-xa2a.google.com (mail-vk1-xa2a.google.com [IPv6:2607:f8b0:4864:20::a2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C9E02D4A for ; Thu, 11 May 2023 01:15:05 -0700 (PDT) Received: by mail-vk1-xa2a.google.com with SMTP id 71dfb90a1353d-44fd6c24d5aso2990362e0c.3 for ; Thu, 11 May 2023 01:15:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683792904; x=1686384904; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=8J5AyuQb7KXDhIq7T1eUiZkECmH3AgrEkNzwG7/4Y1k=; b=KgCLnWvpzk8wO6112cUpK908N2b+S2E470158cKhpD6VK5oDTWwT6KWU0jTB0folPt iefqzxmp4BSYgHduOrq7Mn2L0x28DVzikB/uPlCqj4ljkyp9RKAItujtQKjQZIfJfcC8 nlAz1+6W8yIlBmOA+It7lENXJGIzxJp8KFQ7kGa8hbnrLfmbeO9B8plIqtxs4Vg8M0kA FKYOToPEXquxE8ApDoE0sNKif1eU0K3G9sN4WfV9NcjbwdILdqM4DFnqB7MsrGwytwFu GD0nvDmfY8n6CKognNQD5kbhGuCTivQlpyz3rJToYunhRewjgHsWq4OJH8CeW6Hp5NyY RLiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683792904; x=1686384904; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8J5AyuQb7KXDhIq7T1eUiZkECmH3AgrEkNzwG7/4Y1k=; b=CC0dN5zjUpBsfMScqXMboZtcyuwBWu8jfy95bUxOiUK2ZHFP0Th9ezZ/Ikw2i82nHG KrSH04XNAMf2RS5ynIhcVV9/SL6uR6y+6eIblTwOOJ7XrlSpD3MeCepL1VzOr80gOVPM I5c5hwY6/z3Wiz/BhzTAiF8MU5wHVcLpUlPJLQRI/goxCpQOcDOxFncG2JO9zIIU08Ak iWzPV1Wc3hUWrjZV2rDu9xhUwpr2VoYEMxw61P7VN8SkqSKKbA1BLZbQIithqPskGNnb 2b6Eqzl4W7uGt8at1O9CiNtqGbv0YWD9tuC6h485zq6M3ColFra8H6pLIo2uWE1iFD1+ ujUQ== X-Gm-Message-State: AC+VfDzergksHnzUP5YCCJfBZXAOK94T5ApPihALraqK7WRXJRMyMlp5 nVXUFUZJDZco47VCFb8h8X7L2nAW8yUyLA+6k3mn+A== X-Received: by 2002:a1f:bfd2:0:b0:43f:9aaf:b629 with SMTP id p201-20020a1fbfd2000000b0043f9aafb629mr5416392vkf.0.1683792904155; Thu, 11 May 2023 01:15:04 -0700 (PDT) MIME-Version: 1.0 References: <20230505184318.1355446-1-etienne.carriere@linaro.org> In-Reply-To: From: Sumit Garg Date: Thu, 11 May 2023 13:44:53 +0530 Message-ID: Subject: Re: [PATCH] char: tpm: ftpm_tee: use kernel login identifier To: Etienne Carriere Cc: Jarkko Sakkinen , linux-kernel@vger.kernel.org, Peter Huewe , Jason Gunthorpe , linux-integrity@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 11 May 2023 at 10:36, Etienne Carriere wrote: > > Dearl all, > > Typo in my previous post! > > On Thu, 11 May 2023 at 06:47, Etienne Carriere > wrote: > > > > Hello Jarkko, > > > > On Thu, 11 May 2023 at 00:12, Jarkko Sakkinen wrote: > > > > > > On Fri May 5, 2023 at 9:43 PM EEST, Etienne Carriere wrote: > > > > Changes fTPM TEE driver to open the TEE session with REE kernel login > > > > identifier rather than public login. This is needed in case fTPM service > > > > it denied to user land application and restricted to kernel operating > > > > system services only. > > > > > > > > Signed-off-by: Etienne Carriere > > > > > > > > > Can you bring up a little context here? > > > > > > What is REE login? > > > Does it break backwards compatibility to switch? > > > What kind of scenario we are talking about? What does it mean in plain > > > English when fTPM service is denied. > > > What is fTPM service? > > > > By fTPM service I meant the services exposed by fTPM through its > > OP-TEE interface, that are the commands a client can invoke in fTPM, > > see [1]. > > > > Regarding backward compatibility, this change is backward compatible > > as far as the OP-TEE entity this driver communicates with is of > > revision 3.9.0 or above. > > I understand this case should be addressed in some way. > > > > In current implementation, fTPM can be invoked by Linux kernel drivers > > (through Linux kernel tee API as tpm_ftpm_tee currently does) as well > > as by userland application (through TEE client library API [2]). > > This change makes tpm_ftpm_tee to invoke fTPM interface using a client > > identifier stating it is the Linux kernel that invokes it, not a > > userland application. fTPM implementation does not check the client > > identity when a client opens a session toward it. Therefore using a > > public identifier (TEE_IOCTL_LOGIN_PUBLIC) or the OS privilege > > identifier (TEE_IOCTL_LOGIN_REE_KERNEL) does not matter, as far as > > OP-TEE supports these IDs. The former is native to OP-TEE initial UAPI > > [3], the latter was introduced in OP-TEE 3.9.0 [4] and Linux kernel > > v5.8 [5]. > > > > That said, this change does fix an existing issue in fTPM integration. > > Typo, sorry, I meant > "That said, this change does **NOT** fix an existing issue in fTPM integration." > > BR, > Etienne > > > The fTPM entity currently only accepts a single session opened towards > > it. This is enforced as fTPM sets property TA_FLAG_SINGLE_INSTANCE and > > does not set property TA_FLAG_MULTI_SESSION [6]. > > Linux kernel tpm_ftpm_tee driver currently opens a session to fTPM at > > probe time and releases it at remove time so once the driver is > > successfully probed, no userland application can use TEE userland > > client API to open another session and communicate with fTPM. How about if the fTPM TEE kernel driver is built as a module and removed at runtime by a malicious user-space client? -Sumit > > > > [1] https://github.com/microsoft/ms-tpm-20-ref/blob/main/Samples/ARM32-FirmwareTPM/optee_ta/fTPM/fTPM.c#L456 > > [2] https://github.com/OP-TEE/optee_client > > [3] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=967c9cca2cc50569efc65945325c173cecba83bd > > [4] https://github.com/OP-TEE/optee_os/commit/78f462f646e7c037bea13aa6282c81f255922a4f > > [5] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=104edb94cc4b3101bab33161cd861de13e85610b > > [6] https://github.com/microsoft/ms-tpm-20-ref/blob/main/Samples/ARM32-FirmwareTPM/optee_ta/fTPM/user_ta_header_defines.h#L47 > > > > Regards, > > Etienne > > > > > > > > > --- > > > > drivers/char/tpm/tpm_ftpm_tee.c | 2 +- > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/char/tpm/tpm_ftpm_tee.c b/drivers/char/tpm/tpm_ftpm_tee.c > > > > index 528f35b14fb6..6d32e260af43 100644 > > > > --- a/drivers/char/tpm/tpm_ftpm_tee.c > > > > +++ b/drivers/char/tpm/tpm_ftpm_tee.c > > > > @@ -241,7 +241,7 @@ static int ftpm_tee_probe(struct device *dev) > > > > /* Open a session with fTPM TA */ > > > > memset(&sess_arg, 0, sizeof(sess_arg)); > > > > export_uuid(sess_arg.uuid, &ftpm_ta_uuid); > > > > - sess_arg.clnt_login = TEE_IOCTL_LOGIN_PUBLIC; > > > > + sess_arg.clnt_login = TEE_IOCTL_LOGIN_REE_KERNEL; > > > > sess_arg.num_params = 0; > > > > > > > > rc = tee_client_open_session(pvt_data->ctx, &sess_arg, NULL); > > > > -- > > > > 2.25.1 > > > > > > BR, Jarkko