Received: by 2002:a05:7412:2a8a:b0:fc:a2b0:25d7 with SMTP id u10csp142633rdh; Tue, 6 Feb 2024 23:34:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHvWT9pWmZeSB/0iZZSEtDvu8Sh7HVo5I61V4hUYjrQ9KunvtXvYnr64rSTphIETdtz0PVg X-Received: by 2002:ad4:5b86:0:b0:681:557a:c080 with SMTP id 6-20020ad45b86000000b00681557ac080mr8907292qvp.28.1707291294677; Tue, 06 Feb 2024 23:34:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707291294; cv=pass; d=google.com; s=arc-20160816; b=fo62ktB1nkBwCrJ4bW+28h3Wg+s3HCYhP8fKmzh5s7Hlxb5UNiANWC9tDO1OB5pIyn yCnHKnQqblv/Ofe1NE6Jr7h2i/1tOiQ8XfSMWhGJZ0Oyeo4iOR0tsWcfXA2xbdX0mtPj QPG33tk5H4Gryl7lnMfo1GJCEp2EB8VBxA0jKw6dsU7dqWT+e84i5FZxw54qUAUzw16o q4n3eCRCmv4o3MQzF/TvMeQefnkLa3AsMwB8JtWiwZBOne3w0S4cpMZRCmjBGxlEAb4W 0ZD7XtWOqPGjBBFXLBGtveDBoSzNo1nF6UK0iyVYpR6aeYxCCCHdbg6P6sQx/osQ2ICO iTDQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=S5gO4wFCGdf4U8hpr8PjPSAcXbRHD0h9TiGC7q7YDuY=; fh=DHXuG6ZzrofTSsxPNhmgOnpoarVZScP8FZVIYLqg8Js=; b=C8qqMInE7M6dwu4hiEyfIrsH/4ie0Hh8UQND5WpqspDm4HOR+goRuXyDcTKm73mT71 /WV8bQJTaWmlJG0yLTc4hNaJE19qGrHumttKvLDS7oECb5F5ii3LEpIz1v9h9+Pgonfd 5G+V8w1Y2pQVF5M8tlONEXxK/zcAys4DVb42aKbFb7JnWejoBUhks0bGXUVMr8uw1ZiE vcUrqgdpkij9v99wnz3NuJcFSetGah9lrNeolCra0BacXx5DYznxXr1snXxQ6tvXjEEi eY3LWoc3yBaKjmktUU894bDPUCgeHnwvCOlSZYxI8RzgzPQPgrS8YNmvV6Dw59C08KcZ qwtg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HpDoFKfj; 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-56081-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56081-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=2; AJvYcCWvXKk7VMsLi/eLxaO1zORcd9PYvd7toZ4h7DLOXz87I7JMX1uypf0snq8K4MFiFKZYvPfaBGKbN2G7wzv+36Mqt6thmWwsDC3ZFijReg== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c12-20020ad4430c000000b0068cae96f029si628020qvs.32.2024.02.06.23.34.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 23:34:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56081-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HpDoFKfj; 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-56081-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56081-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 619121C25177 for ; Wed, 7 Feb 2024 07:34:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DB0CA200BE; Wed, 7 Feb 2024 07:34:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="HpDoFKfj" Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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 132DC200A8 for ; Wed, 7 Feb 2024 07:34:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707291286; cv=none; b=SbzhiWxuXva2CqSVd2BVBLP2IiB4C9dEo/4vnLuBKPxV0Ix3aAVSt4fXJOR07LyKQJ1Hg38JpzXZQjobq4FOaFAvDD64Pnk8Tvd4Ev3SM0NmAAVUgm8v9rGaX5D4P5rnG4u6+gZNU6KRx6RDxex70aC6GkUABdYp979RjRCXXuA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707291286; c=relaxed/simple; bh=S5gO4wFCGdf4U8hpr8PjPSAcXbRHD0h9TiGC7q7YDuY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=nLhKWzkWg1WMa8FcnxoPrRkFGj7xNji+f3is5QYVZMubUBDFLI6M0RQR4a/POciIAdAwiNA1XZ5UNwxaDvyY+gRLiziiDdgL0CofvDg1twPI4w62R/xP+DfdTKZ0VbxWXW1hdAF07rihQOm/J49k7e2ALYM+Qqu/6uKLfWrx3DY= 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=HpDoFKfj; arc=none smtp.client-ip=209.85.208.175 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-lj1-f175.google.com with SMTP id 38308e7fff4ca-2d04c0b1cacso3650781fa.0 for ; Tue, 06 Feb 2024 23:34:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707291282; x=1707896082; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=S5gO4wFCGdf4U8hpr8PjPSAcXbRHD0h9TiGC7q7YDuY=; b=HpDoFKfjg80J60h/LJCIAWQPZ7Wwpbwcs5zbuwnVcv0wLGStidAP6qyxmFNLDzejpj rLt8chMKLB5LOqJ3fHNnfPOhLxbfXQqziyElpKR3ElxxOUyfcfAmPqhepF2gthZReAzN 41IYHiFhPPwMUSK909bsaClWQwMT6n5f/MIJsuBXkbXnlBG72TzX1ztzpWFIBbaKaCF3 cuVRNqxdlWjrh4E3xjT8IGeNrSAIEayMxFtdlcaWyS2r7NBzV0CHnj4qymIm+Bx8hqws gpGzPpj8GGPUXY+nXTbSwmlUS2Z3rIPfKmGmXrAcWN/ma9PjPgB6VHivabxiF7JGvunN hpfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707291282; x=1707896082; 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=S5gO4wFCGdf4U8hpr8PjPSAcXbRHD0h9TiGC7q7YDuY=; b=cpguOCTxKD7KrxZi/McbshOpCJydAfyqSxovIFpRyQyTaObQOjF0fCKN0/FjejmnQH rdohhYRD19PUBsAf7ISVCIXMSuoYUmkTgPBgf7e6DPcbopjkdUcxLk5r0YXqppUhUFS3 tzkfQzq+fUg/JTvwmhyJ1M5iZt2hTn2oaZYlSlcB31NRX5nVCCb6/Fk1KHHdESHX3/p0 LxaiJ27dVc/tLXZo+m7T5cU0NGl/MoIIwkKEBrGfZYqFoNMBsN9hg9Lk1XOsXLxbAaP3 9os1zfxbBqzXGatun9YO60vLf1ZeHy7yqhhCGWiq2qEfyzxVGjHdfY77kqZIFn8VjM3n ScyA== X-Gm-Message-State: AOJu0YwA9UzXP4/pX9BjnXbp8n59IVyVM8dp0h+ck8oZXvS8V0/vR0VP gD1hsMdYyAr9bl0FdUZrTUwqFIhP5x0sXp4m+c+bbC42HJWaZhel+jyiRe8hbLwCy6yGqT/v+4W 2MmEC22kX7ds4ly9UjybXXiNOaM14tt4g6iaBGw== X-Received: by 2002:a2e:3509:0:b0:2d0:aa2a:9ced with SMTP id z9-20020a2e3509000000b002d0aa2a9cedmr3421689ljz.6.1707291281948; Tue, 06 Feb 2024 23:34:41 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240131174347.510961-1-jens.wiklander@linaro.org> <20240131174347.510961-2-jens.wiklander@linaro.org> In-Reply-To: From: Ilias Apalodimas Date: Wed, 7 Feb 2024 09:34:05 +0200 Message-ID: Subject: Re: [PATCH v2 1/3] rpmb: add Replay Protected Memory Block (RPMB) subsystem To: Sumit Garg Cc: Ulf Hansson , Jens Wiklander , linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org, op-tee@lists.trustedfirmware.org, Shyam Saini , Jerome Forissier , Bart Van Assche , Randy Dunlap , Ard Biesheuvel , Arnd Bergmann , Greg Kroah-Hartman , Tomas Winkler , =?UTF-8?B?QWxleCBCZW5uw6ll?= Content-Type: text/plain; charset="UTF-8" On Wed, 7 Feb 2024 at 08:11, Sumit Garg wrote: > > Hi Ilias, Ulf, > > On Tue, 6 Feb 2024 at 20:41, Ilias Apalodimas > wrote: > > > > Hi Ulf, > > > > On Tue, 6 Feb 2024 at 14:34, Ulf Hansson wrote: > > > > > > On Wed, 31 Jan 2024 at 18:44, Jens Wiklander wrote: > > > > > > > > A number of storage technologies support a specialised hardware > > > > partition designed to be resistant to replay attacks. The underlying > > > > HW protocols differ but the operations are common. The RPMB partition > > > > cannot be accessed via standard block layer, but by a set of specific > > > > RPMB commands: WRITE, READ, GET_WRITE_COUNTER, and PROGRAM_KEY. Such a > > > > partition provides authenticated and replay protected access, hence > > > > suitable as a secure storage. > > > > > > > > The initial aim of this patch is to provide a simple RPMB Driver which > > > > can be accessed by the optee driver to facilitate early RPMB access to > > > > OP-TEE OS (secure OS) during the boot time. > > > > > > How early do we expect OP-TEE to need RPMB access? > > > > It depends on the requested services. I am currently aware of 2 > > services that depend on the RPMB > > - FirmwareTPM > > - UEFI variables stored there via optee. > > > > For the FirmwareTPM it depends on when you want to use it. This > > typically happens when the initramfs is loaded or systemd requests > > access to the TPM. I guess this is late enough to not cause problems? > > Actually RPMB access is done as early as during fTPM probe, probably > to cache NVRAM from RPMB during fTPM init. Also, there is a kernel > user being IMA which would require fTPM access too. So we really need > to manage dependencies here. Ah true. I was wrongly assuming loading is a module and having systemd or something similar handling that dependency. But in case this is built-in we do need to handle that internally. > > > > > For the latter, we won't need the supplicant until a write is > > requested. This will only happen once the userspace is up and running. > > The UEFI driver that sits behind OP-TEE has an in-memory cache of the > > variables, so all the reads (the kernel invokes get_next_variable > > during boot) are working without it. > > > > Thanks > > /Ilias > > > > > > The way things work for mmc today, is that the eMMC card gets > > > discovered/probed via a workqueue. The work is punted by the mmc host > > > driver (typically a module-platform-driver), when it has probed > > > successfully. > > It would be nice if RPMB is available as early as possible but for the > time being we can try to see if probe deferral suffices for all > use-cases. > > > > > > > The point is, it looks like we need some kind of probe deferral > > > mechanism too. Whether we want the OP-TEE driver to manage this itself > > > or whether we should let rpmb_dev_find_device() deal with it, I don't > > > know. > > I wouldn't like to see the OP-TEE driver probe being deferred due to > this since there are other kernel drivers like OP-TEE RNG (should be > available as early as we can) etc. which don't have any dependency on > RPMB. > > How about for the time being we defer fTPM probe until RPMB is available? > > -Sumit