From: Pavan Chebbi <pavan.chebbi@broadcom.com>
To: michael.chan@broadcom.com, kuba@kernel.org
Cc: andrew+netdev@lunn.ch, andrew.gospodarek@broadcom.com,
davem@davemloft.net, edumazet@kernel.org, netdev@vger.kernel.org,
pabeni@redhat.com, Shravya KN <shravya.k-n@broadcom.com>,
Vishvambar Panth S <vishvambar.panth-s@broadcom.com>,
Pavan Chebbi <pavan.chebbi@broadcom.com>
Subject: [PATCH net 4/4] tg3: Fix heap overflow in unbuffered NVRAM write path
Date: Sun, 8 Nov 2026 12:25:26 +0530 [thread overview]
Message-ID: <20261108065526.710152-5-pavan.chebbi@broadcom.com> (raw)
In-Reply-To: <20261108065526.710152-1-pavan.chebbi@broadcom.com>
From: Shravya KN <shravya.k-n@broadcom.com>
tg3_nvram_write_block_unbuffered() reads a whole NVRAM page into a
buffer of pagesize bytes, copies the caller's data into it at page_off,
and writes the page back. The copy size was clamped to pagesize rather
than to the room left in the page, pagesize - page_off, so a write at an
offset that is not page aligned, as ETHTOOL_SEEPROM allows, copies past
the end of the buffer and corrupts the kernel heap.
Clamp size to pagesize - page_off. Also advance buf by size on each
iteration, as the data of a write that spans pages was otherwise taken
from the start of the caller's buffer for every page.
This was found by an AI code review scan. It has not been triggered, so
the issue is theoretical.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reviewed-by: Vishvambar Panth S <vishvambar.panth-s@broadcom.com>
Reviewed-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: Shravya KN <shravya.k-n@broadcom.com>
Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
---
drivers/net/ethernet/broadcom/tg3.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 16f8368874e7..5b5b21d759a6 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -3399,13 +3399,14 @@ static int tg3_nvram_write_block_unbuffered(struct tg3 *tp, u32 offset, u32 len,
break;
page_off = offset & pagemask;
- size = pagesize;
+ size = pagesize - page_off;
if (len < size)
size = len;
len -= size;
memcpy(tmp + page_off, buf, size);
+ buf += size;
offset = offset + (pagesize - page_off);
--
2.52.0
next prev parent reply other threads:[~2026-11-08 6:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-08 6:55 [PATCH net 0/4] tg3: Bug fixes Pavan Chebbi
2026-11-08 6:55 ` [PATCH net 1/4] tg3: Don't fail probe if 31-bit coherent DMA mask is unsupported Pavan Chebbi
2026-11-08 6:55 ` [PATCH net 2/4] tg3: Select PLL clock when preparing for shutdown Pavan Chebbi
2026-11-09 7:49 ` netdev-bot+sashiko
2026-11-09 9:24 ` Pavan Chebbi
2026-11-08 6:55 ` [PATCH net 3/4] tg3: Skip querying for management FW when no NCSI present Pavan Chebbi
2026-11-08 6:55 ` Pavan Chebbi [this message]
2026-11-09 7:49 ` [PATCH net 4/4] tg3: Fix heap overflow in unbuffered NVRAM write path netdev-bot+sashiko
2026-11-09 9:22 ` Pavan Chebbi
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=20261108065526.710152-5-pavan.chebbi@broadcom.com \
--to=pavan.chebbi@broadcom.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew.gospodarek@broadcom.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=michael.chan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shravya.k-n@broadcom.com \
--cc=vishvambar.panth-s@broadcom.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