From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 B8E97421EE6 for ; Tue, 26 May 2026 18:20:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779819638; cv=none; b=diOMiB4qGozJ5P21cskmTCvN6Gf/vo3PBR7LtQ22oYEKysuq2QFtKGl2lUCZJKIz3YJbsMwHPCcRO28eLJ2IQA5PxKCTOUnCXKEofbbiWo9MjT7x7zXWDgh3/7QOGrwNsIN08s9FxeelGTtcaJTJrwvW8yC3jkpp8v10CAbQDoo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779819638; c=relaxed/simple; bh=I4ytr2AWirUEzmeLuOnc/4U0/hxql28G8RhQSyhu0CI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Tqr7hRW60tkY2VMr/wTPjyqB89ggGzGlVAK716vfhh+Bl7hfTYHleBm60/VOpj300Cw14tvFFZh2nvoUr5K+dGHLlMjgjFax5dKgEA2k1S5V7+Y09JJtjhh9iFSg9yc6utDBqiClQ97D4MpjARgfzHk6DcXCA9uW7Q5Kxstmgxs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-490388fd0dbso53646635e9.0 for ; Tue, 26 May 2026 11:20:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779819633; x=1780424433; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MHH3yPE1r4W1hBBuLJyFdGXQJe8rCYCaC0Nwz7rJsCs=; b=Z9kIwYrFSjAdeakNPoYLRo8RkXmoUDdupcq0cwYt8DD0XjtwvetU7FLqxIVyUCQqyI mJ0HMJg2vEYILehmFK3Y8+QTjMNlIegUOdpX0eoBX0qoSv17//QNbOcx/bny6+if1lVT t7c+XFhELvWiFxAXtHDEzLC9QfTW4cmKtlyrb+cw2Hrth5EfxaSW1WqNPgw6UbHz3M3a WRuFAZD9r7Km5Vpi7AlpEJVK7lp27KDNZWpFdQlin7VxQkYUhQddmw1qlKtypbruPa2f /PICVWKLjVN4dfzV0kdlyEPuHUo6SeFrSdXm7ld8gqYE+sRzbzGFauNZ+Xb6esbBCatW 4Ikg== X-Forwarded-Encrypted: i=1; AFNElJ9MlC/hh/Gm8L5btlSKsKAjhySQ7THcWxzDWo00p8Vy4NaerzEQh7dGm55lGUKs/xm8o8hafUgbT2BMbrs=@vger.kernel.org X-Gm-Message-State: AOJu0Yz05XhDEwpArJcUQEXHVf5WdxKAlf4hpHH6uL6atTCUUtg9mA2g +dzzZK/8ZWAaN/AScO+QFl6wx87XMWQfj4ppGG4JhbbDCi3BUmCIzsgI X-Gm-Gg: Acq92OGp9GvA9yoeHEvAAMecyqcbcZ3ghrDRcH/tRvs3ikAEKgUMIFTNLBqKH/aNNIO 6XsGnVOLqPmJs3xJaXQidoC5rN2v/iZMJ5jV0xNhlYV4RHNYsA6u6ZsIwS5ncfJHLq0CyN5sui5 cNt5jLqv34rbrlysN5C4Mi9BtNhlfHEaD0pHPjLsEQS9oduH1wMUbqSlAJBWBHT25y7KyO3H5rU LkcmKrTD+c3w6bLja+wExLfCnknrCwciFN6DwKawcyjmiCks+9NZj/bHrrHaWyFnLrhP8Vm2m0K gnD7EFZ7EsZOQDgfj6MhVKbjZUKXbxvftO2j3hAC2/LiVGrenmipPN6InclXOxvBPEJRbKCInh8 jugFxQctlNS4SeyXrLxpp+N4S0SGKSf/SaNotsvU3ELeSfmQJV/pP2MkpSkRNeN8N5Zdz4rpv83 dYlmEdaBPscdzdDD+OJYMz/SccLYltE/ztyV3KpatN/XypC2k= X-Received: by 2002:a05:600c:444b:b0:490:b07:5fd1 with SMTP id 5b1f17b1804b1-490424aa00fmr304755965e9.11.1779819633114; Tue, 26 May 2026 11:20:33 -0700 (PDT) Received: from gmail.com ([62.197.47.167]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45eb6d5cb9asm40641882f8f.27.2026.05.26.11.20.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2026 11:20:32 -0700 (PDT) Date: Tue, 26 May 2026 19:20:31 +0100 From: Breno Leitao To: Jarkko Sakkinen Cc: Peter Huewe , Jason Gunthorpe , linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, noodles@fb.com, James.Bottomley@hansenpartnership.com, kernel-team@meta.com Subject: Re: [PATCH] tpm: cap tpm_buf_append() at TPM_BUFSIZE, not PAGE_SIZE Message-ID: References: <20260524-tpm-v1-1-2420a5977da6@debian.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: Hello Jarkko, On Mon, May 25, 2026 at 02:24:38AM +0000, Jarkko Sakkinen wrote: > On Sun, May 24, 2026 at 10:01:17AM -0400, Breno Leitao wrote: > > tpm_buf_append() guards against overflow of the underlying buffer by > > comparing the running length against PAGE_SIZE. Every other site in the > > TPM core uses TPM_BUFSIZE (4096) as the protocol-level cap on TPM > > command and response sizes. > > > > On 4K-page kernels PAGE_SIZE == TPM_BUFSIZE, so the two caps coincide > > and the inconsistency is invisible. On kernels with a larger base page > > size, e.g. CONFIG_ARM64_64K_PAGES=y or 16K pages, PAGE_SIZE exceeds > > TPM_BUFSIZE. > > > > This is a latent bug rather than user-visible bug, given most of the > > cases PAGE_SIZE = 4096. The mismatch is still worth fixing because > > future callers (e.g. the proposed TPM_BUFSIZE increase to 8 KiB, and the > > Secure Launch tpm_buf rework) rely on the overflow flag being > > authoritative. > > > > Use TPM_BUFSIZE instead of PAGE_SIZE so the append-time check > > matches the transmit-time cap on every page size. > > > > Signed-off-by: Breno Leitao > > Fixes: a74f8b36352e ("tpm: introduce tpm_buf") > > --- > > There is no bug w/o a sympton of some sort. Not sure what the problem is here. Sorry, there is no current problem in here, but there is inconsistency. There isn't a real problem today, just an inconsistency and what I called a latent bug, let me justify myself. Everywhere else in the TPM core uses TPM_BUFSIZE as the protocol cap, but this particular site uses PAGE_SIZE instead. Since PAGE_SIZE >= TPM_BUFSIZE, it doesn't cause any issue at the moment. That said, I still think the change is worthwhile for two reasons: 1. Consistency with the rest of the TPM core. 2. Decoupling TPM_BUFSIZE from PAGE_SIZE, so that if TPM_BUFSIZE ever grows beyond PAGE_SIZE[1], this code won't silently break. That's what I was referring to as a "latent bug" — though admittedly that phrasing was probably too strong. Link: https://lore.kernel.org/all/20260518151724.730443-6-armenon@redhat.com/ [1] Thanks for the review, --breno