From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796400601; b=irFUNb0txhqsaps1AV3EoEP1bRCUy+PLM2TzSSAjDG6y9lfjFoCUBZBMbphPr2FU6IUs RJhnbIYGG2PAhCi5meImxN1czBTudSP6hGDv7dL6VzPkzzbQB2M+aq21lOMgnsohdPER1 UGJVAHNHdcQq4pYYHWChjGTZA3b9ZBH6QCSUrIErX8bah3XK+ZjSFLYDjgkx0tU3Q1oOP 4ogfxSqE37/ngsczsv6wdARTYkPyyBtPdTWeeqECL5t3LkTLUK/V1fUzdvEo1XBAW0zIZ cKEzz39GE7Isv4Ucmu1YAxJYvPhEhfHtvCIuGELNZXpzG63XUJZZHybV+kIgvqnnhUw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796400601; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=uyCgUiChcd2khVBYScBimiwlXKryqH0V8CUgDEUGLk0=; b=qTzZtdp/uwB7DlnF8mwDuul0RMMcGh4kCYy/D4B61B5mQVJWXboklZ5vDHq26QrIDuCO KOIsqAtiRZ+nKaxSPobd+itl6B3Uu95LXB+EUF54B8/aSRQSwwmPSEf4sibqBmGJxJT0g i+97V/+wbDoKRqHF9rnn8VCRkHFZKxboRzyGlhy98kDAjZQru+mUcc8EI3Z6rrVeEEeMa /aP0NBMSyHdiPppJe2lakSb8N2sGTZOY04yLnubyq4o6z/kZoVwSzdEnbH/Q040FvscFH vxVIXHaQUKoq4pNR7iQEy6FMJnRvv8BCIWmXVNOcKaFGmpSG3w6FhwPoJ/PW8HnFMRQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Iu8GJ6i4; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 853B2606A322 for ; Fri, 4 Dec 2026 16:10:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Iu8GJ6i4 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B82021F000CE; Fri, 4 Dec 2026 16:10:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796400601; bh=uyCgUiChcd2khVBYScBimiwlXKryqH0V8CUgDEUGLk0=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Iu8GJ6i4cnPAUDT2roV5BQ+tB0jnwmAbwj0cQsuvpo26l3MRipCg7KWKHOYI3FOeD rrx6xqgcvWc55FEPj/DwrsKPsqvFLRilVEIJHEwYXS5mLg7fqblNKIs+7q/VwSuQlP VSpLAMzE21u3v1VOsdAmlKGHa1GGjm74JuXZO1zGjR8Ne+SVu4/N5wsuz/2i2Y7kvF mOSXSRBCX6FrWvG9Sgij7vsmyZD9p2T0pk7aDZneFqPPD8pBdabz5x4NAtumfViu4+ cnF/nLhHhK6w6qWWTGDrMjaA5ZA1+esY+vmDe6n9xwDyaR9cJ7okNUg3EgV1bXefIf A1+Eg2Zhc4bbQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4] tpm: loongson: bound the response by the DMA window Reply-To: sashiko-reviews@lists.linux.dev To: "Fang Xieyan" , "Qunqin Zhao" , "Peter Huewe" , "Jarkko Sakkinen" Cc: "Jason Gunthorpe" , "Lee Jones" , "Huacai Chen" , "Yinggang Gu" , linux-crypto@vger.kernel.org, "Lin Qiaojie" In-Reply-To: <20261204155246.60786-1-fangxy@xiaopeng.com> References: <20261204155246.60786-1-fangxy@xiaopeng.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 16:10:00 +0000 X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] tpm: loongson: untested firmware ABI change in tpm_loongson_probe() -- commit 4578f644ae7983bb4262bd7e41b5d35fe9618363 Author: Fang Xieyan tpm: loongson: bound the response by the DMA window This commit bounds the response length read by tpm_loongson_recv() against the engine's DMA buffer size using READ_ONCE(), and writes buffer_size into the first reserved word of struct tpm_loongson_cmd during tpm_loongson_probe(). > diff --git a/drivers/char/tpm/tpm_loongson.c b/drivers/char/tpm/tpm_loong= son.c > index 9e50250763d16..59f3947bec5d5 100644 > --- a/drivers/char/tpm/tpm_loongson.c > +++ b/drivers/char/tpm/tpm_loongson.c > @@ -12,20 +12,22 @@ struct tpm_loongson_cmd { > u32 cmd_id; > u32 data_off; > u32 data_len; > - u32 pad[5]; > + u32 buffer_size; > + u32 pad[4]; > }; [ ... ] > @@ -61,6 +63,7 @@ static int tpm_loongson_probe(struct platform_device *p= dev) > cmd =3D tpm_engine->command; > cmd->cmd_id =3D SE_CMD_TPM; > cmd->data_off =3D tpm_engine->buffer_off; > + cmd->buffer_size =3D tpm_engine->buffer_size; [Severity: Medium] Can writing a non-zero value to cmd->buffer_size break deployed Security Engine firmware that expects reserved words in struct tpm_loongson_cmd to be zero? loongson_se_probe() allocates the shared DMA region with dmam_alloc_coherent(), so this word was previously always zero and no firmware version check guards it. If existing firmware rejects non-zero reserved fields, TPM command execution will break on existing platforms. Because tpm_loongson_recv() already prevents the out-of-bounds read on the host side without cmd->buffer_size, and this patch targets stable without hardware testing, splitting the cmd->buffer_size change into a separate patch tested against deployed firmware would avoid that regression risk. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204155246.6078= 6-1-fangxy@xiaopeng.com?part=3D1