From: sashiko-bot@kernel.org
To: "Fang Xieyan" <fangxy@xiaopeng.com>,
"Qunqin Zhao" <zhaoqunqin@loongson.cn>,
"Peter Huewe" <peterhuewe@gmx.de>,
"Jarkko Sakkinen" <jarkko@kernel.org>
Cc: "Jason Gunthorpe" <jgg@ziepe.ca>,
"Yinggang Gu" <guyinggang@loongson.cn>,
"Lee Jones" <lee@kernel.org>,
"Huacai Chen" <chenhuacai@kernel.org>,
linux-crypto@vger.kernel.org, "Lin Qiaojie" <linqj@xiaopeng.com>
Subject: Re: [PATCH v3] tpm: loongson: reject an undersized DMA window
Date: Wed, 02 Dec 2026 12:00:21 +0000 [thread overview]
Message-ID: <sashiko-outbox-245648@kernel.org> (raw)
In-Reply-To: <20261202114445.37551-1-fangxy@xiaopeng.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] tpm: loongson: probe rejects 4KB DMA window due to 8KB
TPM_BUFSIZE
--
commit 99e627b732ef70357aa6e5acc30fcca7ecbd8581
Author: Fang Xieyan <fangxy@xiaopeng.com>
tpm: loongson: reject an undersized DMA window
This commit rejects Loongson TPM devices whose per-engine DMA window is
smaller than TPM_BUFSIZE at probe time and reads cmd_ret->data_len once
with READ_ONCE() in tpm_loongson_recv().
> diff --git a/drivers/char/tpm/tpm_loongson.c b/drivers/char/tpm/tpm_loongson.c
> index 9e50250763d16..bbb131097d39f 100644
> --- a/drivers/char/tpm/tpm_loongson.c
> +++ b/drivers/char/tpm/tpm_loongson.c
[ ... ]
> @@ -58,6 +60,13 @@ static int tpm_loongson_probe(struct platform_device *pdev)
> tpm_engine = loongson_se_init_engine(dev->parent, SE_ENGINE_TPM);
> if (!tpm_engine)
> return -ENODEV;
> +
> + if (tpm_engine->buffer_size < TPM_BUFSIZE) {
> + dev_err(dev, "TPM DMA window too small: %u < %u\n",
> + tpm_engine->buffer_size, TPM_BUFSIZE);
> + return -EINVAL;
> + }
> +
> cmd = tpm_engine->command;
> cmd->cmd_id = SE_CMD_TPM;
> cmd->data_off = tpm_engine->buffer_off;
[Severity: Medium]
Does checking tpm_engine->buffer_size < TPM_BUFSIZE cause a probe
regression on platforms with a 4096-byte per-engine DMA window (64 KiB
total dmam_size)?
The commit message assumes TPM_BUFSIZE is 4096, but commit 1e41cfc5549c
("tpm: Increase TPM_BUFSIZE to 8KB for chunking support") raised
TPM_BUFSIZE in include/linux/tpm_command.h to 8192 so the core can build
larger commands for transports with chunking while smaller fixed-window
transports enforce their own buffer limits in send() and recv().
Requiring buffer_size >= TPM_BUFSIZE here rejects 4 KiB windows with
-EINVAL and makes the count > tpm_engine->buffer_size check in
tpm_loongson_send() unreachable because tpm_try_transmit() already clamps
transfers to TPM_BUFSIZE.
Could tpm_loongson_recv() bound data_len against both count and
tpm_engine->buffer_size instead?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202114445.37551-1-fangxy@xiaopeng.com?part=1
prev parent reply other threads:[~2026-12-02 12:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 11:44 [PATCH v3] tpm: loongson: reject an undersized DMA window Fang Xieyan
2026-12-02 12:00 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-245648@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=chenhuacai@kernel.org \
--cc=fangxy@xiaopeng.com \
--cc=guyinggang@loongson.cn \
--cc=jarkko@kernel.org \
--cc=jgg@ziepe.ca \
--cc=lee@kernel.org \
--cc=linqj@xiaopeng.com \
--cc=linux-crypto@vger.kernel.org \
--cc=peterhuewe@gmx.de \
--cc=sashiko-reviews@lists.linux.dev \
--cc=zhaoqunqin@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.