Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp704154rdb; Thu, 22 Feb 2024 17:59:04 -0800 (PST) X-Forwarded-Encrypted: i=4; AJvYcCXRNR81T7CZe0w13H8vIdqesiO1xN83Fo7afKKYts4dM/T/eIBm2NLSt0cIO2CsX30j2C/FSlPxEIwnGsWEPlD/SM/9I2emUQK3M7bX0g== X-Google-Smtp-Source: AGHT+IGuSag2r77NJ0YTrARqFnPFDDdYcLU7jeYXR8OegIXKbueFmxXPiExEd2toHkg/te2Nqtjj X-Received: by 2002:a05:6808:1408:b0:3c0:3545:6402 with SMTP id w8-20020a056808140800b003c035456402mr657804oiv.55.1708653544589; Thu, 22 Feb 2024 17:59:04 -0800 (PST) ARC-Seal: i=3; a=rsa-sha256; t=1708653544; cv=pass; d=google.com; s=arc-20160816; b=cPf/zNVWW3pjHtrL9uBKfJgiboJrLZWCH9lrhM/P1jjWv3LT8eSMJ4MNUtFm3bTeyO CsmIKCtbDU8XeUqIvc7UlvGFcOuS3DKGTQXpv+mYmoevPsr4dYQTYf+K4Ui1SLFgiPvZ Dd+cOSSFDNZqtbPbOVAp1npcFsfZc4FJMagSObbVkSLMOE8lqVwZdeNODhTmMXW7hPAZ Wm7LU7/hpyJAXuyHefBeRdCU5x9JZ5tyfnLCenoXKJ/DjwHAhzil0jGBOCozotvnEpIt cNax1IskhFdeEOUqh94HYvw03Fg1wgeuINZy7+oPrJa7PsowFg1MU0itXQ4AWbNeHpO5 e4uw== 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=0c/9UXs3DUULMzn59Y2UYaZS5a9by2Pn5MZ9zDCNofc=; fh=dXinPnf2Djqg3Wt/uje5dzIGXJxf346rgCVTDGh6O8w=; b=I1aAKGZq1bZbBRBwlZaJIvRwxFdRy8PT5rmC6i0Nlmxo+vda7muG70N4Yaba/uCAEI 1iTeJE5FjxGlwj/VFVFt9lpo1ggxAvSz7tinMoFFLFWr/rOP5dWO4L3DoMpOdGintiSJ JAVojDGNCzsSzjRRhKMMbeFuN9DTayoPCLtA45ESejoQaVQtTQVJeh/Q/5WndSC98N+s XDBgVIZmZ4LtoekxVYpEn4ZSgNpkDNYTXaNKA2sKUCCsMU+TeNKrJbL7tgKL+PG7oBru 1u+A/sNcbfSWF3iPAXh0d2/A5FtsYy/V3guRDGikTbKnHiH5/NKA72jJ7hCGcrJ6zZ6E 4i9g==; dara=google.com ARC-Authentication-Results: i=3; mx.google.com; dkim=pass header.i=@apertussolutions.com header.s=zoho header.b=E0kby1gR; arc=pass (i=2 spf=pass spfdomain=apertussolutions.com dkim=pass dkdomain=apertussolutions.com); spf=pass (google.com: domain of linux-kernel+bounces-77666-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77666-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id t13-20020aa78f8d000000b006de378fb498si11078453pfs.249.2024.02.22.17.59.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 17:59:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77666-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@apertussolutions.com header.s=zoho header.b=E0kby1gR; arc=pass (i=2 spf=pass spfdomain=apertussolutions.com dkim=pass dkdomain=apertussolutions.com); spf=pass (google.com: domain of linux-kernel+bounces-77666-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77666-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 3A79728614B for ; Fri, 23 Feb 2024 01:59:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 43936B67F; Fri, 23 Feb 2024 01:58:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=apertussolutions.com header.i=dpsmith@apertussolutions.com header.b="E0kby1gR" 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 DA7663209; Fri, 23 Feb 2024 01:58:54 +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=1708653536; cv=pass; b=R61wdvOrMDvliqjCL7xfVtRT6v5at+Nwk38jLRKSLp/7JlTQDC/k3Gl3WnxNmWPYoAqO31XUu3TggTRU13zMz30I4YhjbIsJFxoPFtf8NbMOsXWiHgWgdC9TF3N1cJtyRAN4SCVHR6oRU3SPWC+rVwN6Wp7Sf4l/5NVX6maM0FE= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708653536; c=relaxed/simple; bh=5WSYiRG0da1c48/HAqdyQzrAWeMUGqbq0I7r1FGiB2o=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=n7rxkQorG4aUoejdfFwCgPcapive1diXxMWzXhG/KqbepwDm2dD1gWAVk4w+FNxcKATEI20iUdr2sMWSG3nXjB0StnOeckNW5yxbMU5d8Rn3Y3AzaaN83Bk982VsOLR6fhg7a3H5cYlzqXmAsafrzA09wBWUJpdLge/+R3iA5Uo= 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=E0kby1gR; 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=1708653524; cv=none; d=zohomail.com; s=zohoarc; b=cjiEo2im1vcFKw2Q1SOdLZUt4fE9dUoL84U3+dTryleoXrqMP/ddTUAavE4mBzY8QCP2F9XvFB3zDq0urQvxmp/1pDOhj8O/ngiw1YFq8vv6fsWgqmFQqtWlC3CFk/xwfFlsz/oZAnPK98Il3noFIe+YXM6fuzQWoI9lq6HOjBQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708653524; 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=0c/9UXs3DUULMzn59Y2UYaZS5a9by2Pn5MZ9zDCNofc=; b=TGvkGcZfXFDdEUU+5h/felsDdkuBNL9QRckJMK7ZDXP3YOaeG2N0Mrmfo3Q/y5xjVumMZzSKzDtLEbZwvjA3lMVQ4gxtg1SVwNKJIMN+YfYiMRZwS3qNTeDtALJXhBpevkizimQRl846PbtBv0f7UvV8l9N90JakFqF78vOSaq4= 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=1708653524; 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=0c/9UXs3DUULMzn59Y2UYaZS5a9by2Pn5MZ9zDCNofc=; b=E0kby1gRBtS+r+5qRZAKkD77mQH5+7O7TNPBYqtdZ2urCmuFvXtWv3icZhBjISm/ IOYZuBTMfNy5OJ20r6q/FNetjloXoreSlppBP7V4O80lQMe3/caf0SIkt08bPWbTUvc 2Is16gaXyiv/QP2528TJY9/8wEJppM2w7G4NA9rM= 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 1708653523228943.4732868395558; Thu, 22 Feb 2024 17:58:43 -0800 (PST) Message-ID: <88b75c9c-98ab-4474-8112-6a27d11a2fdf@apertussolutions.com> Date: Thu, 22 Feb 2024 20:58:40 -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: Jarkko Sakkinen , Lino Sanfilippo , Alexander Steffen , 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/aRzj4ksFYPzLkJbWLZGBRlv7HQLvs6i/K4y/b4fs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Transfer-Encoding: 7bit X-ZohoMailClient: External On 2/20/24 17:23, Jarkko Sakkinen wrote: > On Tue Feb 20, 2024 at 8:54 PM UTC, 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. > > Usually, or at least use cases I'm aware of, localities are per > component. E.g. Intel TXT has one and Linux has another. > > There's been some proposals in the past here for hypervisor specific > locality here at LKML they didn't lead to anything. > > If you are suggesting of removing "int l" parameter altogether, I > do support that idea. > >> But this is rather code optimization and not really required to fix >> the reported bug. > > Just adding here that I wish we also had a log transcript of bug, which > is right now missing. The explanation believable enough to move forward > but I still wish to see a log transcript. That will be forth coming. v/r, dps