From: Thierry Reding <thierry.reding@kernel.org>
To: Pengpeng Hou <pengpeng@iscas.ac.cn>
Cc: Jonathan Hunter <jonathanh@nvidia.com>,
Timo Alho <talho@nvidia.com>,
linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] firmware: tegra: bpmp: reject truncated debugfs entries
Date: Tue, 18 Aug 2026 13:30:17 +0200 [thread overview]
Message-ID: <aoQ-lEhC6ReM1eMS@orome> (raw)
In-Reply-To: <20260814080548.22922-1-pengpeng@iscas.ac.cn>
[-- Attachment #1: Type: text/plain, Size: 1566 bytes --]
On Fri, Aug 14, 2026 at 04:05:48PM +0800, Pengpeng Hou wrote:
> The BPMP debugfs parser reads fixed-width values and bounded strings
> from a size-delimited reply. Its fixed-width helper currently treats a
> short copy as success, while the string helper advances past the range
> when no NUL terminator is present. The status helper also uses an
> unsigned return type for negative errors.
>
> Require complete fixed-width reads and a terminator within the remaining
> range before moving the cursor. Use a signed status result so errors
> reach callers unchanged.
>
> Fixes: f2381f652266 ("firmware: tegra: Add BPMP debugfs support")
>
> Assisted-by: Codex:gpt-5
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
> ---
> Changes since v1: https://lore.kernel.org/all/20260715083726.30740-1-pengpeng@iscas.ac.cn/
> - no source-code changes
> - rebase on the current Tegra firmware sources and tighten the commit message
> - add the coding-assistant disclosure
>
> The bounded parser helpers and callers were reviewed statically; no
> malformed BPMP response was injected.
>
> drivers/firmware/tegra/bpmp-debugfs.c | 17 +++++++++++++----
> 1 file changed, 13 insertions(+), 4 deletions(-)
This doesn't make sense to me. The seqbuf_read*() helpers already use
seqbuf_avail() to make sure they never read past the end of the buffer.
We also leave scope immediately anytime we see an overflow.
Worst case we'll see memcpy() copy 0 bytes, as far as I can tell, and
that's harmless (even though not entirely free).
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2026-08-18 11:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 8:05 [PATCH v2] firmware: tegra: bpmp: reject truncated debugfs entries Pengpeng Hou
2026-08-18 11:30 ` Thierry Reding [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=aoQ-lEhC6ReM1eMS@orome \
--to=thierry.reding@kernel.org \
--cc=jonathanh@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=pengpeng@iscas.ac.cn \
--cc=talho@nvidia.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox