From: Jacob Keller <jacob.e.keller@intel.com>
To: Chenguang Zhao <chenguang.zhao@linux.dev>,
<jiawenwu@trustnetic.com>, <mengyuanlou@net-swift.com>,
<andrew+netdev@lunn.ch>, <davem@davemloft.net>,
<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>
Cc: <maxime.chevallier@bootlin.com>, <netdev@vger.kernel.org>,
Chenguang Zhao <zhaochenguang@kylinos.cn>
Subject: Re: [PATCH net] net: txgbe: fix heap overflow when reading module EEPROM
Date: Tue, 14 Jul 2026 17:31:42 -0700 [thread overview]
Message-ID: <cd326f52-274c-456b-aa67-75ff8cc3500c@intel.com> (raw)
In-Reply-To: <20260713085111.1481884-1-chenguang.zhao@linux.dev>
On 7/13/2026 1:51 AM, Chenguang Zhao wrote:
> From: Chenguang Zhao <zhaochenguang@kylinos.cn>
>
> txgbe_read_eeprom_hostif() always copies round_up(length, 4) bytes
> into the caller buffer, which ethtool allocates with exactly 'length'
> bytes. A non-4-aligned length therefore causes an out-of-bounds write.
> Copy only the remaining bytes on the final dword instead.
>
> Signed-off-by: Chenguang Zhao <zhaochenguang@kylinos.cn>
> ---
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
> drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c
> index affea1a364ef..26d0cfc58ee2 100644
> --- a/drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c
> +++ b/drivers/net/ethernet/wangxun/txgbe/txgbe_aml.c
> @@ -96,11 +96,13 @@ int txgbe_read_eeprom_hostif(struct wx *wx,
> dword_len = round_up(length, 4) >> 2;
>
> for (i = 0; i < dword_len; i++) {
> + u32 copy_len = min_t(u32, 4, length - i * 4);
> +
> value = rd32a(wx, WX_FW2SW_MBOX, i + offset);
> le32_to_cpus(&value);
>
> - memcpy(data, &value, 4);
> - data += 4;
> + memcpy(data, &value, copy_len);
> + data += copy_len;
> }
>
> return 0;
prev parent reply other threads:[~2026-07-15 0:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-13 8:51 [PATCH net] net: txgbe: fix heap overflow when reading module EEPROM Chenguang Zhao
2026-07-13 9:17 ` Jiawen Wu
2026-07-15 0:31 ` Jacob Keller [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=cd326f52-274c-456b-aa67-75ff8cc3500c@intel.com \
--to=jacob.e.keller@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=chenguang.zhao@linux.dev \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jiawenwu@trustnetic.com \
--cc=kuba@kernel.org \
--cc=maxime.chevallier@bootlin.com \
--cc=mengyuanlou@net-swift.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=zhaochenguang@kylinos.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox