Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp139051lqp; Tue, 11 Jun 2024 18:14:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUNKy32Q1J2uzwa3Ui00ekG2fOAHImfupy/q0G23hw7G/tlfAFUgaMvKXEiArrAL1tGr6f6VoWJIcHL2oPyzrIIy5pg7rCVe+ZYVD84pg== X-Google-Smtp-Source: AGHT+IGnyJUGyGP+/Hb4zeFW1bX7FjEXIAXpjvPCSzFYSbnkgwqjW8hxIrFVAqyDnQU0dSl8PAeQ X-Received: by 2002:a17:907:9445:b0:a6e:f869:dfcd with SMTP id a640c23a62f3a-a6f47f52d65mr19844366b.6.1718154864673; Tue, 11 Jun 2024 18:14:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718154864; cv=pass; d=google.com; s=arc-20160816; b=lwWuX23RX9IunS9xO0LFVKOg6HDo/CoQzWZuHt1jFFL41L7lNUTVJTCesRznQ+vqvI XzRxYNXX7lJzjqGWBJIlQdCLb86pSUHo57WAHrpSaNASuBKYWiRCC5VVqvXk3T+mBhH7 RxAl51X2jAXmp4h58hTAn/2xWEcx8OkdIMvxKRHq7itz0E0YaczP87E8LauH63pBBX6u Woy/S/m2VEo/BqxUlsDYr/KQzYxs1wiGUB3VX3gk+OEBvL8v5C3M21JMwV9+Srt2UF+B VG4dzc/KSjVX1x2rq/8o2HNLnQP1gd8/MuHhu0UyyoPiujW+RWRKsKu+RV0TR7BkQAFZ W/tQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=RixUhrZoJxC5ZGEX/bQjHSbR4r7wmqVUu8WN9NYTkWY=; fh=JfhX17GnxqPbtrqOkYiv6pWtMwZriLA1BYIkmHHqC34=; b=CEukV7p79w189oZvaTzrHf1TbSTCsVfa8FQblmHi80ArsQ7vSEHQnc53Vgywo3cmEC bBLr9n6we8ks5dK7zD7ItIs02zXg8SMQdRvBhJ631Kj5hdcveeBmB9qGViPcjLFpDvc5 vFJ3+Egyu2t0GLo4wTDxOZRJY0usogGiB9wXZHLwp5MxSP3bD7FesV2eh+iJLMaUtxC7 zhB/qwNMVW+Dd2pqGr8RUUqd5Am/t6EsyLbOMneB3Q//PldKRbwNxoNozUbuOzajYao+ kxWZfygghuZmhht40Dd4aQ44LizZvt8xF9EZq+nO5OzUIvjReM6Bi1JE49rgLkkRAPgV flhg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KXM7ZUOG; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-210743-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210743-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6c806db09fsi606317566b.348.2024.06.11.18.14.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 18:14:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-210743-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KXM7ZUOG; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-210743-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210743-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0E4481F23BAA for ; Wed, 12 Jun 2024 01:14:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 53E6D3C39; Wed, 12 Jun 2024 01:14:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="KXM7ZUOG" Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0745A15D1 for ; Wed, 12 Jun 2024 01:14:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.66 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718154855; cv=none; b=h7ma3xXsmMdYh+GrivEYSQt6TfNIC6LoIP/bA8wTl7w/fiPK6Lp6eiKHhE/GjegnZSR/ErVvgg4sEoUCuOZRkQxu5wGeIgP0DBz2rDdax0kk73ZTm0nvH88CPZsJVXj0TmtL2CuuJcyyuKYvp3ntZ9pLqyrRGhPexew+NOvoPoQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718154855; c=relaxed/simple; bh=IikKDHkoHWntmqY/dLBV8XUv+R26hd+jl1ntJJKqZAw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hsIInXTDNjv3d4elCSzQ5pkgM79RuiS0L+c+tX/Kn8C/Xjvu33FwIKX441QYqTIEhWxyHb5cYtXHHWsOTML1dezQCZsXXYTY2nzWS6aSCOP+vOQKI0ZDLKE9iST7UOnDO6qqi5eNzwqqUi6y3GXBTQcsBpJnFg5trDHLJsKCho8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=KXM7ZUOG; arc=none smtp.client-ip=209.85.216.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-pj1-f66.google.com with SMTP id 98e67ed59e1d1-2c2e72128b4so342227a91.0 for ; Tue, 11 Jun 2024 18:14:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718154852; x=1718759652; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=RixUhrZoJxC5ZGEX/bQjHSbR4r7wmqVUu8WN9NYTkWY=; b=KXM7ZUOG8a8gVe+FyG7ibVMqzsUrn43jkBGn5Vj9+KaGNmYWs+mVZuR7NBrhy0QS1w TjW+b16h3RIz4h+E7Bmn2Fqxwf0EdJZrXCAUUszgANIXXmIMbnFO8WQyheBu6M1jIE+F Qe5ostjELugrgAI7399FwQijHQILsuJLQiQDNmB07TgCcvyTJa0wUQCHLcUD1/8JY04W p9txzwZDbOy0xsTZnXU3GxckYJt8+YqqmlczJt6xlgWzYxFxu2ERdhOM5UYHbZM9gaNu 8xbkph2EZMp1o0PbXcIuCbHuQHnawACWgKbijGAJqpfwR0Xo72v96qlQQr/YNT4iX3Ry dzig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718154852; x=1718759652; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=RixUhrZoJxC5ZGEX/bQjHSbR4r7wmqVUu8WN9NYTkWY=; b=P6c4Eq39oD3zOaQzERJoyxLSgmhJL0H/qnNpd0NsqCfNTN8mVGBTaMrjC8a7W+XOrB JvbQP77FN4q90zLVr0Zrj4BI7L/VkAOzlwAzJ5i1zjonPB0yqskNk66LVGP0pJ53HkF8 HAdAVRtH2u1BCk0/EBBJJ0cyfo7LDOyYmVIuxEe0Ie9EDhCeTx8fanuSH7Ta14hUevwP I8iGEJkiDH+NUdSI9Ag/CU/MGYdwZ3+79uERD3CZrYE75EFWJL+vcUhWsU8yploIuO6J 5SPtcH63a1jINcO07OgyRZ/5lrbo7e0xy09ORgj2I5V6C3uWhAVGYInkiDt/VK0RtFSq 8lfg== X-Forwarded-Encrypted: i=1; AJvYcCVewhrjLo+Ak2Moj6arsKnjdRJ/Fd8VYOpdKqmcclk+JesAa1g2lloh+iekaO9OQ89Du3Emf9zdNB0AquYlxJld8DeTp0gOs76MLfCY X-Gm-Message-State: AOJu0YyDpBtDOUE3vP5T/5Pl2SWe5rykEWhFZmVJkulUb24S6/DfvkLs iLdCPBVImBBx7Z6PsiUiEMeXgSEr6/oXYwe0aJFo03y+t24u+OuwQ87z9mggvdw= X-Received: by 2002:a17:90a:5b15:b0:2c2:264a:a021 with SMTP id 98e67ed59e1d1-2c32b4894f4mr5761692a91.10.1718154852182; Tue, 11 Jun 2024 18:14:12 -0700 (PDT) Received: from nuoska ([2405:6580:800:9800:b841:9d1f:6a68:11b2]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c4a76aa11fsm272362a91.47.2024.06.11.18.14.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 18:14:11 -0700 (PDT) Date: Wed, 12 Jun 2024 10:14:02 +0900 From: Mikko Rapeli To: Sumit Garg Cc: Jens Wiklander , Manuel Traut , linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org, op-tee@lists.trustedfirmware.org, Shyam Saini , Ulf Hansson , Linus Walleij , Jerome Forissier , Ilias Apalodimas , Bart Van Assche , Randy Dunlap , Ard Biesheuvel , Arnd Bergmann , Greg Kroah-Hartman , Peter Huewe , Jarkko Sakkinen , Jason Gunthorpe , linux-integrity@vger.kernel.org Subject: Re: [PATCH v7 4/4] optee: probe RPMB device using RPMB subsystem Message-ID: References: <20240527121340.3931987-1-jens.wiklander@linaro.org> <20240527121340.3931987-5-jens.wiklander@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Hi, Adding TPM maintainers and linux-integrity since discussion relates to firmware TPM driver tpm_ftpm_tee On Tue, Jun 11, 2024 at 04:13:21PM +0530, Sumit Garg wrote: > On Tue, 11 Jun 2024 at 08:32, Mikko Rapeli wrote: > > > > Hi, > > > > On Mon, Jun 10, 2024 at 02:52:31PM +0200, Jens Wiklander wrote: > > > Hi Manuel, > > > > > > On Mon, Jun 3, 2024 at 11:10 AM Manuel Traut wrote: > > > > > > > > On 14:13 Mon 27 May , Jens Wiklander wrote: > > > > > --- a/drivers/tee/optee/ffa_abi.c > > > > > +++ b/drivers/tee/optee/ffa_abi.c > > > > > @@ -7,6 +7,7 @@ > > > > > > > > > > #include > > > > > #include > > > > > +#include > > > > > #include > > > > > #include > > > > > #include > > > > > @@ -903,6 +904,10 @@ static int optee_ffa_probe(struct ffa_device *ffa_dev) > > > > > optee->ffa.bottom_half_value = U32_MAX; > > > > > optee->rpc_param_count = rpc_param_count; > > > > > > > > > > + if (IS_REACHABLE(CONFIG_RPMB) && > > > > > + (sec_caps & OPTEE_FFA_SEC_CAP_RPMB_PROBE)) > > > > > + optee->in_kernel_rpmb_routing = true; > > > > > > > > The SEC_CAP_RPMB_PROBE flag seems to be missing in optee_os at the moment. > > > > If I remove this check here, the series works for me. > > > > > > You're right, I missed pushing those flags to optee_os. I've pushed them now. > > > > Thanks! Tested with optee 4.1 and your patches from > > https://github.com/jenswi-linaro/optee_os/commits/rpmb_probe_v7/ > > in Trusted Substrate uefi firmware > > ( https://gitlab.com/Linaro/trustedsubstrate/meta-ts/ ) > > and this series and a bunch of dependencies backported to > > our Trusted Reference Stack > > ( https://trs.readthedocs.io/en/latest/ ) > > 6.6.29 kernel on rockpi4b (rk3399 ARM64 SoC) with secure boot and > > the optee side fTPM TA device used to create an encrypted rootfs with > > systemd. Kernel side RPMB routing is in use and works for the TPM use cases. > > > > Glad to see that you can get fTPM to work without tee-supplicant after > this patch-set. Sorry but the fTPM TA only works with tee-supplicant in userspace. It's needed for RPC setup. For RPMB it is not needed or used with these patches applied. > > Full boot and test log (with unrelated test failures) > > https://ledge.validation.linaro.org/scheduler/job/88692 > > > > root@trs-qemuarm64:~# cat /sys/class/tee/tee0/rpmb_routing_model > > ... > > kernel > > So coming back to the real question, do we really need this new > rpmb_routing_model ABI? Did systemd still need it with no > tee-supplicant dependency? IMHO, a user-space ABI requires use-case > justification otherwise it's just going to add on maintenance burden. Currently it is not needed, because tee-supplicant is still required to setup RPC with fTPM. If the RPC setup were also done in kernel directly and tee-supplicant need is removed, then this kind of ABI is important so that userspace init knows if it needs to queue startup of tee-supplicant or not. On a related note, the kernel tpm_ftpm_tee driver for fTPM TA really has a hard dependency to tee-supplicant in userspace. If tee-supplicant is stopped, restarted etc without unloading the kernel module (or otherwise disabling the TPM device), then all TPM device actions done without tee-supplicant running will fail ane keep failing until next reboot. The kernel driver is not crashing but all functionality breaks. The availability of tpm_ftpm_tee should be tied much harder to the tee-supplicant running in userspace, e.g. optee should be in charge to start and bring tpm_ftpm_tee down based on tee-supplicant userspace daemon availability. Or the needed tee-supplicant code should be moved to kernel side. Currently systemd side init scripts have issues switching from initrd to main rootfs since they need to disable tpm_ftpm_tee driver, built in or a module, before shutting down tee-supplicant. A suspend or other inactive state in the ftpm driver needs to be triggered, which AFAIK is not currently possible, at least from userspace (I'd happy be proven wrong here). An alternative for tpm_fptm_tee driver is to use optee APIs so that the calls wait for tee-supplicant in userspace if needed: --- a/drivers/char/tpm/tpm_ftpm_tee.c +++ b/drivers/char/tpm/tpm_ftpm_tee.c @@ -237,6 +237,9 @@ static int ftpm_tee_probe(struct device *dev) return PTR_ERR(pvt_data->ctx); } + /* wait for tee-supplicant in userspace, fTPM TA really depends on it */ + pvt_data->ctx->supp_nowait = false; + /* Open a session with fTPM TA */ memset(&sess_arg, 0, sizeof(sess_arg)); export_uuid(sess_arg.uuid, &ftpm_ta_uuid); This works pretty well for the tee-supplicant initrd to main rootfs switch but currently breaks for example reboot (just hangs), and Jens doesn't approve of this as a real solution. So as an alternative, userspace needs to be very careful in initrd and rootfs to start tee-supplicant earlier than loading tpm_ftpm_tee driver which can only be supported as module and removed before shutting down tee-supplicant. In other use cases, TPM drivers are only supported if driver is built into the kernel (or ACPI table entry for a TPM device exists) which I'm trying to change with [PATCH] efi: expose TPM event log to userspace via sysfs https://lore.kernel.org/lkml/20240422112711.362779-1-mikko.rapeli@linaro.org/ where userspace init can check if it should wait longer for the tpm device to appear, e.g. let udev load optee etc drivers which eventually start also tee-supplicant and thus load tpm_ftpm_tee driver (fTPM TA enumration is tied to tee-supplicant in userspace https://git.yoctoproject.org/meta-arm/tree/meta-arm/recipes-security/optee-ftpm/optee-ftpm/0001-add-enum-to-ta-flags.patch ) Cheers, -Mikko