From: Aibing Chen <chenaibing@cmss.chinamobile.com>
To: netdev-bot+sinfo@kernel.org
Cc: Saeed Mahameed <saeedm@nvidia.com>,
Leon Romanovsky <leon@kernel.org>,
Tariq Toukan <tariqt@nvidia.com>, Mark Bloch <mbloch@nvidia.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] net/mlx5: fix a stack over-read in the QP debugfs files
Date: Fri, 20 Nov 2026 17:53:40 +0800 [thread overview]
Message-ID: <20261120095340.1564-1-chenaibing@cmss.chinamobile.com> (raw)
In-Reply-To: <179516120532.3291.16859269248680746966@kernel.org>
Hi,
How it was found: by code inspection, not from a report or a tool - while
looking at how the mlx5 debugfs field readers use the return value of
snprintf().
Was it triggered: no, I did not reproduce it at runtime. It is statically
decidable from the code: snprintf() returns the length the output would
have had (23 for "Invalid transport type" plus the newline) instead of the
number of bytes written (18), and simple_read_from_buffer() uses that
value to bound the copy to userspace. It is only reachable when the
device reports a QP transport value that mlx5_qp_type_str() does not name.
Hardware: not tested on real hardware, I do not have mlx5 hardware
available. The change only uses scnprintf() so that the length passed to
simple_read_from_buffer() can no longer exceed the buffer, and enlarges
the buffer so that the longest string still fits; neither needs device
specific behaviour.
Thanks,
Aibing Chen
prev parent reply other threads:[~2026-11-20 9:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 7:50 Aibing Chen
2026-11-20 7:53 ` netdev-bot+sinfo
2026-11-20 9:53 ` Aibing Chen [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=20261120095340.1564-1-chenaibing@cmss.chinamobile.com \
--to=chenaibing@cmss.chinamobile.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mbloch@nvidia.com \
--cc=netdev-bot+sinfo@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeedm@nvidia.com \
--cc=tariqt@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
all inboxes | Powered by JetHome®