Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1206699rbb; Mon, 26 Feb 2024 02:03:33 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVZ23dUqILovSZs9HsI7hU+7jV+dqbLXfxpN5axF4maMKHRQ9O9+gV/GweWI5GJ+5TMlFktG827VoySHEebzDmNXuRDrxAiFzGybD1Cfg== X-Google-Smtp-Source: AGHT+IFCrjNt08GWTtVpNIAAAyc7LMCvpjjrjaq66Uuj8OJvejhUZNGXRAzrak/GNvjhd04M6q2m X-Received: by 2002:a05:620a:46ac:b0:787:d87f:bda6 with SMTP id bq44-20020a05620a46ac00b00787d87fbda6mr968648qkb.70.1708941813467; Mon, 26 Feb 2024 02:03:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708941813; cv=pass; d=google.com; s=arc-20160816; b=Rv2NwNPlymMWGbvvAOdq9lD+ulWNMuUps8EoBHLJpUVLq7Dw/RHNpDURszuoaaQ1AT yBmi6reuRdS9sAlKluetl8vAqv1r05v/0nYubrFpykobjfY6027ZdNfF69ehhxr+zB4a jV61/R0wAhRK8UskStjC2ongMALgDJWmrYMw+UBmX9Ud2Tk71n7/17Y6FOSu2BCtiMJX eBG5vGF65gfv1V16ybXJ+Kt63TKKkn59zVj85UIhIqPuj0I/i0JX5MBh9LRwnQUiqRq9 B88ix/zU5DBhVltxwDOkqH3JKSNluXgcQ8Z1AIGZrur6lcvbaZibDXQ35Fl6QtzGUvpu m22w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=hhG00OyEDeWdYwOZW6NZDyKXB/h/3F2ZEF/AqLqkOj8=; fh=TrV30TWp7aueuLOlw/8DeLBuSKNMQfs1IbCyEGztiOw=; b=KKrxHdXFo+XGtbjsdF13P/N46jxDLZetQhawBfLbo5PEGuOJPclxVCeN6IX6vJ8XLl tMPR3bjRxtacOEXlPPR6EcST+oPssNI4gaBkvlQLTsVeTZUro+9YVcZ829CnvFtQvb9q PLi8R3EUDkWpNl5JJSju7H4rBBxnQUoJBlbcNYqhgFLax5q+p+eQi+aMGNP0/jOI98I/ PLpcOtT+La6vr4ND+KTClDDEDsE3bBNzLmKr/snYheX/M0A7LxmnUyZrLPeLul5pvFFV 6Mjh1JPwwqtPwDA+pKtrm8uaY6VLmJhweW53jw81QOSw9ZokJOOPj8qVbdfh1ay1bW3K zZpw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ndpY59ga; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-81068-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81068-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ya2-20020a05620a5e4200b0078769904e35si4563534qkn.219.2024.02.26.02.03.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 02:03:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81068-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ndpY59ga; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-81068-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81068-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.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 EC4881C25C74 for ; Mon, 26 Feb 2024 10:02:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E31BE5D728; Mon, 26 Feb 2024 09:38:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ndpY59ga" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1517F5D49A; Mon, 26 Feb 2024 09:38:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708940324; cv=none; b=OHjl8Sd9hotWBNobIw4CJZdouh0XNbETSPDPcKpYa2KDGe9bgvvqTm5Px+xOc60y0dAxtZALYylUcfxGd3F3BWf6AamQvQdujXxmFtte7y4QYNYZAa7Y2n2uBsTJ0ZVGG3XUTVtcbZNcOGAyPmgIHFh0zXWAF0K+XORJKOJcJFQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708940324; c=relaxed/simple; bh=hhG00OyEDeWdYwOZW6NZDyKXB/h/3F2ZEF/AqLqkOj8=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=JLzbkzGWD5rbPBMH1kAFgOTTe6hc9sgX9yt8kVPTL7h70LMAj2GFcNSluawh8yIqq44EYfHoTwr6upz3JOCecqy75vSEdDotGiwkGWh6lEnqCpt9c3JPZ9AU7G9jO7r4gbXFwIC+zewNG7Vk+yRoSc4+TjaUtYKiv9qh78BoQGo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ndpY59ga; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BE6BC433F1; Mon, 26 Feb 2024 09:38:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708940323; bh=hhG00OyEDeWdYwOZW6NZDyKXB/h/3F2ZEF/AqLqkOj8=; h=Date:Cc:Subject:From:To:References:In-Reply-To:From; b=ndpY59gaX5H/LlbJgo0UuXF1oSj6Xg2eZvHSb/62FfoQj7dXzoOEzjqHpXaRxdjeW N6J+awVv5/pINt0vdAxc83xdEm7dw9ZKBKZ13wT6zI4gkHePQuEFj1/qZwG/dpdyPz svLgGz0DQwc4CM4Y24TLXzqWf3MpQBWIAeXeARk8W9R2YutToSWPSv/8/LIoVJIF+2 mGUi0hXd+rnnjR5yTemGuSr7S5ISUTBPHslaOdXv5+NNBIHLxfou8aQeM/107eFjSl m1qJ9rhvIm7Ol0fjuEVEnWqsxcdUahD/paGBAdLFVrQtcIzIsLwidZ6dBIdvMyOBS/ kOVf1xkieH6Lw== Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 26 Feb 2024 11:38:39 +0200 Message-Id: Cc: "Ross Philipson" , "Kanth Ghatraju" , "Peter Huewe" Subject: Re: [PATCH 1/3] tpm: protect against locality counter underflow From: "Jarkko Sakkinen" To: "Lino Sanfilippo" , "Daniel P. Smith" , "Alexander Steffen" , "Jason Gunthorpe" , "Sasha Levin" , , X-Mailer: aerc 0.15.2 References: <20240131170824.6183-1-dpsmith@apertussolutions.com> <20240131170824.6183-2-dpsmith@apertussolutions.com> <2ba9a96e-f93b-48e2-9ca0-48318af7f9b1@kunbus.com> <91f600ef-867b-4523-89be-1c0ba34f8a4c@kunbus.com> <8692fcf6-2e67-45b4-b809-7723f30736a2@apertussolutions.com> <75642d53-9daa-4be7-8d3d-d1d86bc60b3e@kunbus.com> In-Reply-To: <75642d53-9daa-4be7-8d3d-d1d86bc60b3e@kunbus.com> On Sat Feb 24, 2024 at 4:34 AM EET, Lino Sanfilippo wrote: > > > On 23.02.24 02:56, Daniel P. Smith wrote: > > >> > >> Will the TPM TIS CORE ever (have to) request another locality than 0? = Maybe the best would > >> be to hardcode TPM_ACCESS(0) and get rid of all the locality parameter= s that are > >> passed from one function to another. > >> But this is rather code optimization and not really required to fix th= e reported bug. > >=20 > > Actually, doing so will break the TPM API. The function > > tpm_tis_request_locality() is registered as the locality handler, > > =C2=A0int (*request_locality)(struct tpm_chip *chip, int loc), in the t= is > > instance of struct tpm_class_ops{}. This is the API used by the Secure > > Launch series to open Locality2 for the measurements it must record. > >=20 > > I dont understand this. How do you use locality 2 with the current mainli= ne > API? Do you adjust the mainline code to use locality 2 instead of 0? This= would=20 > at least explain how you ran into the underflow issue which from > the source code seems to be impossible when using locality 0. But then I = wonder why > this has not been made clear in this discussion. And then we are talking > about fixing a bug that does not even exist in the upstream code.=20 Thanks for bringing this up, now I finally figured out what confuses me in this series. Daniel, I also have troubles understanding why locality_count would ever be greater than zero exactly in the mainline kernel, *without* [1]? [1] https://lore.kernel.org/linux-integrity/20240214221847.2066632-1-ross.p= hilipson@oracle.com/ BR, Jarkko