Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp703591rdb; Thu, 22 Feb 2024 17:57:08 -0800 (PST) X-Forwarded-Encrypted: i=4; AJvYcCVVCM8ytwPwk4uVCcQwcH8vrbnh9aScnp6vdUD2BFajTY/oG5GIg3mfUpFiLiuuPn612U3/aPqyUBa5jIFT8l45QlCmDjoE2X9TvD3p6w== X-Google-Smtp-Source: AGHT+IEckHjDZOHJgV97qSoxAxsXn1cVConSJcES2Hhi/7qPn/RWwK0/KnsysbQbwZQTQUud9aTm X-Received: by 2002:a17:903:41ca:b0:1db:d66e:cd15 with SMTP id u10-20020a17090341ca00b001dbd66ecd15mr779647ple.59.1708653427776; Thu, 22 Feb 2024 17:57:07 -0800 (PST) ARC-Seal: i=3; a=rsa-sha256; t=1708653427; cv=pass; d=google.com; s=arc-20160816; b=UfoL86uZXhpUzQ4B1ss2+whpJZ1XeJo2qJkSGsIcIXWSnaiAVdKXLcO4yQqOBUI4pt QssUQ165nfZyWGP28ShbaYx3YhfUQ4xhStMGZRHHnhEL5cpqKxnQW2VB6mB9LLkCrnen Uo2Pps1zuCm5OwQ4bQKLZuKRVjuJ80qmMgHs0qrFUlC7nxHq+tDGhXJeRMhy0IAUIFWH 4XrrYgeAf64cX/h8oIOFE5Ko57HmK86++DQAwoVl1WFdexh1MTLGPWymvBRKmnYpbKAy AaPWt2U6G3uVYjyuWQCxF1y44M9Uo1hmDzYCM5Z6IvteRxOf8b80lAfYb/Wd1lvp1OgV zzcw== ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=sktCtrgdX9oXeDsPtkRDIn02qGb7twDfK/vT/fJTMgw=; fh=yX2NaMGvwA6+h84OGgNAD9PWK5gXQ55m3yc1Yqb7wAk=; b=bPzI7nOVcMuyZMzUfgLLpuivTNdsuIpm+GeLFTLHwIztLSzIJOhZ7z9bQzA8/sRflS hTeTggNtuFpvLUWDzxXexi+oFPEHJ+ZFSeRlgJkhacX8CE8EcIRfwXIv3tXdXcM1RCZL mk4Y35Tym+lYi1srIHoeRRFrIm0Z6AxCThSKm9/iYbdequ24z1GZi76MJFUhCg84fgNr THLF96vVwqI5iCakS2l9MfjD2lCNGPj8/uoUjc/O0OTsi22hwXiwBPkEWBsVUDiezwY3 OwUne869KAWpUqo9NMkX27XHo+60asmGd7jzq2bGOGhAlgRdE/F/+qMyB2uXfPQD4Hl0 h7AA==; dara=google.com ARC-Authentication-Results: i=3; mx.google.com; dkim=pass header.i=@apertussolutions.com header.s=zoho header.b=UeOmDSVs; arc=pass (i=2 spf=pass spfdomain=apertussolutions.com dkim=pass dkdomain=apertussolutions.com); spf=pass (google.com: domain of linux-kernel+bounces-77661-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77661-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id s14-20020a170902ea0e00b001dc38eaa5casi3903594plg.74.2024.02.22.17.57.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 17:57:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77661-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@apertussolutions.com header.s=zoho header.b=UeOmDSVs; arc=pass (i=2 spf=pass spfdomain=apertussolutions.com dkim=pass dkdomain=apertussolutions.com); spf=pass (google.com: domain of linux-kernel+bounces-77661-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77661-linux.lists.archive=gmail.com@vger.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id AFE7CB22953 for ; Fri, 23 Feb 2024 01:57:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6801FBA2B; Fri, 23 Feb 2024 01:56:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=apertussolutions.com header.i=dpsmith@apertussolutions.com header.b="UeOmDSVs" Received: from sender4-of-o50.zoho.com (sender4-of-o50.zoho.com [136.143.188.50]) (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 A96F42F3A; Fri, 23 Feb 2024 01:56:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.50 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708653412; cv=pass; b=AxmPFhWs268eanQhUEigSQC43AqEgW2lDnM7rxOQNDJnTD1DJzsjVDYkyWQTjOoG2lJpuZkVuyrNYDoLj/kUZ8JlzAWyxEiWn6+R3Ai4R3GyZfuvhaj0XoJ2BXEgydUjGpBYedQuYPqFX7ghbL59eh7r9DWidxIPRrrIp8SCbxM= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708653412; c=relaxed/simple; bh=uRL9X4CgQfTwlta9uZ0/fWdNW9GR1FuidHD4aSERdSE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=rAkxpOexYB4k2LZNejnSI82i7rkOx9/VvlizKhBT5nAD4Nmh2QtjHxM64+E8jfj8CUIhu5MB9flYub6sVZVzY3gx4SXKW7yWFYGgaS6T+2Ol5qrhwtRChtkKjvB2bC6Dxg6N2ygjOjokOLiFh5LlticnEcosCbZR4jp0iRKHcdQ= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=apertussolutions.com; spf=pass smtp.mailfrom=apertussolutions.com; dkim=pass (1024-bit key) header.d=apertussolutions.com header.i=dpsmith@apertussolutions.com header.b=UeOmDSVs; arc=pass smtp.client-ip=136.143.188.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=apertussolutions.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=apertussolutions.com ARC-Seal: i=1; a=rsa-sha256; t=1708653398; cv=none; d=zohomail.com; s=zohoarc; b=cRUnt8ZYIQ29X48zsF3h+kd12D70WGXCzBM87ZsRLg2ZNhSDwJq037/9NV03W/BoE/gDmqvUNtmGcZHT/xw4P3sFPtTZidd+LkH8R9ncA0a2mkD4GJg7P4GRf0K1bYlHFfYO/ZmWa9im09v4Biab3DRLdiNTnCvZJ6ywS3eCN4E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708653398; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=sktCtrgdX9oXeDsPtkRDIn02qGb7twDfK/vT/fJTMgw=; b=hh6e2Spp3zOPgdd4maegpCj/rUlXqDsOq8vpeVfSyUAHi1J1GDDRKLXQ1xypXTIDdsIhK1uQWvEHdwxHQ2AJq8DzuvrdvAXDY7bJ0ct+gCPAA8EpmJM94Mo5poWrevWv2LcHPbGU7v4I/58sNVOsaPci0q0vv82158UM4perFbA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=apertussolutions.com; spf=pass smtp.mailfrom=dpsmith@apertussolutions.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1708653398; s=zoho; d=apertussolutions.com; i=dpsmith@apertussolutions.com; h=Message-ID:Date:Date:MIME-Version:Subject:Subject:To:To:Cc:Cc:References:From:From:In-Reply-To:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=sktCtrgdX9oXeDsPtkRDIn02qGb7twDfK/vT/fJTMgw=; b=UeOmDSVsLsxuwTftEUN4ksImLKvROzrkx7G89ecMCK29RHB5ErxlCWsN14QKM2ie Rp2lK7Kwadk+OHO3gnxvjqjATNeQStcOtsNQcAUhopTPo1erOtBn3bEpnKZngrtEhcq ckGbeBomSwHLlNMSCwKaIaYWK1Ch3QW85x+wJOhI= Received: from [10.10.1.138] (static-72-81-132-2.bltmmd.fios.verizon.net [72.81.132.2]) by mx.zohomail.com with SMTPS id 1708653396398484.41371917200786; Thu, 22 Feb 2024 17:56:36 -0800 (PST) Message-ID: <8692fcf6-2e67-45b4-b809-7723f30736a2@apertussolutions.com> Date: Thu, 22 Feb 2024 20:56:33 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/3] tpm: protect against locality counter underflow Content-Language: en-US To: Lino Sanfilippo , Alexander Steffen , Jarkko Sakkinen , Jason Gunthorpe , Sasha Levin , linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ross Philipson , Kanth Ghatraju , Peter Huewe 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> From: "Daniel P. Smith" Autocrypt: addr=dpsmith@apertussolutions.com; keydata= xsJuBFYrueARCACPWL3r2bCSI6TrkIE/aRzj4ksFYPzLkJbWLZGBRlv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523-89be-1c0ba34f8a4c@kunbus.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ZohoMailClient: External On 2/20/24 15:54, Lino Sanfilippo wrote: > Hi, > > On 20.02.24 19:42, Alexander Steffen wrote: >> ATTENTION: This e-mail is from an external sender. Please check attachments and links before opening e.g. with mouseover. >> >> >> On 02.02.2024 04:08, Lino Sanfilippo wrote: >>> On 01.02.24 23:21, Jarkko Sakkinen wrote: >>> >>>> >>>> On Wed Jan 31, 2024 at 7:08 PM EET, Daniel P. Smith wrote: >>>>> Commit 933bfc5ad213 introduced the use of a locality counter to control when a >>>>> locality request is allowed to be sent to the TPM. In the commit, the counter >>>>> is indiscriminately decremented. Thus creating a situation for an integer >>>>> underflow of the counter. >>>> >>>> What is the sequence of events that leads to this triggering the >>>> underflow? This information should be represent in the commit message. >>>> >>> >>> AFAIU this is: >>> >>> 1. We start with a locality_counter of 0 and then we call tpm_tis_request_locality() >>> for the first time, but since a locality is (unexpectedly) already active >>> check_locality() and consequently __tpm_tis_request_locality() return "true". >> >> check_locality() returns true, but __tpm_tis_request_locality() returns >> the requested locality. Currently, this is always 0, so the check for >> !ret will always correctly indicate success and increment the >> locality_count. >> > > 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 parameters that are > passed from one function to another. > But this is rather code optimization and not really required to fix the reported bug. Actually, doing so will break the TPM API. The function tpm_tis_request_locality() is registered as the locality handler, int (*request_locality)(struct tpm_chip *chip, int loc), in the tis 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. v/r, dps