Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH net v3 0/3] tg3: Bug fixes
  2026-11-18 10:54 [PATCH net v3 0/3] tg3: Bug fixes Pavan Chebbi
@ 2026-11-18 10:52 ` netdev-bot+sinfo
  2026-11-18 10:54 ` [PATCH net v3 1/3] tg3: Don't fail probe if 31-bit coherent DMA mask is unsupported Pavan Chebbi
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: netdev-bot+sinfo @ 2026-11-18 10:52 UTC (permalink / raw)
  To: Pavan Chebbi
  Cc: michael.chan, kuba, andrew+netdev, andrew.gospodarek, davem,
	edumazet, netdev, pabeni

Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - What hardware the change was tested on. For driver fixes please
   mention the device (and if relevant firmware version) used for
   testing, or say that the change was not tested on real hardware.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.

*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
-- 
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net v3 0/3] tg3: Bug fixes
@ 2026-11-18 10:54 Pavan Chebbi
  2026-11-18 10:52 ` netdev-bot+sinfo
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Pavan Chebbi @ 2026-11-18 10:54 UTC (permalink / raw)
  To: michael.chan, kuba
  Cc: andrew+netdev, andrew.gospodarek, davem, edumazet, netdev, pabeni,
	Pavan Chebbi

This patchset has 4 fixes.  The first patch restores probe on 57766 when
the 31-bit coherent DMA mask cannot be set.  The second patch makes NCSI
PLL lock on the TLP clock to fix WOL at 1G speed on 5720.  The third
patch fixes ethtool -i display on 5719/5720 when NCSI component is
missing.  The fourth one fixes a possible heap overflow in the NVRAM
write path.

v3: Dropped patch #2 (PLL clock source) from the series.  It is being
    reworked and will be resubmitted after the reporter has tested it.
    Addressed Sashiko warnings on:
 - patch #2 (was #3 in v2) to describe the version register as holding no
   valid data, instead of "uninitialized memory", to correct the Fixes tag
   to 165f4d1cb3d7, and to document the return value of tg3_probe_ncsi().
 - patch #3 (was #4 in v2) to reject an NVRAM page size that is smaller than
   4 or not a power of two, instead of only a zero page size.

v2: Addressed Sashiko warnings on:
 - patch #2 such that the PLL clock bit is set only at system suspend and
   power off, cleared on resume and at probe and updated under the APE lock.
 - patch #4 to reject a zero NVRAM page size and to describe the buf advance
   fix and its reach.

v1:
https://lore.kernel.org/all/20261108065526.710152-1-pavan.chebbi@broadcom.com/

Pavan Chebbi (2):
  tg3: Don't fail probe if 31-bit coherent DMA mask is unsupported
  tg3: Skip management FW version when APE firmware is not ready

Shravya KN (1):
  tg3: Fix heap overflow in unbuffered NVRAM write path

 drivers/net/ethernet/broadcom/tg3.c | 43 +++++++++++++++++++++++------
 1 file changed, 34 insertions(+), 9 deletions(-)

-- 
2.52.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net v3 1/3] tg3: Don't fail probe if 31-bit coherent DMA mask is unsupported
  2026-11-18 10:54 [PATCH net v3 0/3] tg3: Bug fixes Pavan Chebbi
  2026-11-18 10:52 ` netdev-bot+sinfo
@ 2026-11-18 10:54 ` Pavan Chebbi
  2026-11-22 11:07   ` netdev-bot+sashiko
  2026-11-18 10:54 ` [PATCH net v3 2/3] tg3: Skip management FW version when APE firmware is not ready Pavan Chebbi
  2026-11-18 10:54 ` [PATCH net v3 3/3] tg3: Fix heap overflow in unbuffered NVRAM write path Pavan Chebbi
  3 siblings, 1 reply; 7+ messages in thread
From: Pavan Chebbi @ 2026-11-18 10:54 UTC (permalink / raw)
  To: michael.chan, kuba
  Cc: andrew+netdev, andrew.gospodarek, davem, edumazet, netdev, pabeni,
	Pavan Chebbi, Rui Salvaterra

Commit 614f4d166eee ("tg3: Set coherent DMA mask bits to 31 for
BCM57766 chipsets") lowered the coherent DMA mask to 31 bits as a
workaround for a spurious address overflow error in the hardware.
The result of dma_set_coherent_mask() is fatal to probe, so on
platforms that cannot satisfy such a mask the device fails to probe:

  tg3 0000:01:00.0: Unable to obtain 64 bit DMA for consistent allocations
  tg3 0000:01:00.0: probe with driver tg3 failed with error -5

This was reported on a Mac mini (Macmini6,2, BCM57766) running a
kernel built without CONFIG_ZONE_DMA and with IOMMU passthrough as
the default. Without CONFIG_ZONE_DMA, dma_direct_supported() only
accepts a mask narrower than 32 bits if it covers the highest
physical memory address, so with direct mapping a 31-bit coherent
mask is rejected whenever memory extends above 2GB.

Treat the 31-bit mask as best effort.  If it is refused, warn and fall
back to the mask used before 614f4d166eee, so that the device still
probes.  Platforms that accept the mask are unaffected.  Where it is
refused, 614f4d166eee never protected the device, it only stopped it
from probing, so this restores the behaviour of kernels before that
commit.  Warn when a status block lands at an address matching the
pattern described in 614f4d166eee, so that a resulting TX timeout can
be identified.

Fixes: 614f4d166eee ("tg3: Set coherent DMA mask bits to 31 for BCM57766 chipsets")
Reported-by: Rui Salvaterra <rsalvaterra@gmail.com>
Link: https://lore.kernel.org/netdev/CALjTZvYKHWrD5m+RXimjxODvpFPw7Cq_EOEuzRi1PZT9_JxF+g@mail.gmail.com/
Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
---
 drivers/net/ethernet/broadcom/tg3.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 95827df4cf6a..2cf9d2ea069b 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -8867,6 +8867,13 @@ static int tg3_alloc_consistent(struct tg3 *tp)
 		if (!tnapi->hw_status)
 			goto err_out;
 
+		if (tg3_asic_rev(tp) == ASIC_REV_57766 &&
+		    (lower_32_bits(tnapi->status_mapping) & 0xffff0000) ==
+		    0xffff0000)
+			dev_warn(&tp->pdev->dev,
+				 "Status block at DMA address %pad may cause TX timeouts on this device\n",
+				 &tnapi->status_mapping);
+
 		sblk = tnapi->hw_status;
 
 		if (tg3_flag(tp, ENABLE_RSS)) {
@@ -17756,6 +17763,7 @@ static int tg3_init_one(struct pci_dev *pdev,
 	u64 dma_mask, persist_dma_mask;
 	netdev_features_t features = 0;
 	u8 addr[ETH_ALEN] __aligned(2);
+	u64 test_dma_mask = 0;
 
 	err = pci_enable_device(pdev);
 	if (err) {
@@ -17895,15 +17903,22 @@ static int tg3_init_one(struct pci_dev *pdev,
 		persist_dma_mask = dma_mask = DMA_BIT_MASK(64);
 
 	if (tg3_asic_rev(tp) == ASIC_REV_57766)
-		persist_dma_mask = DMA_BIT_MASK(31);
+		test_dma_mask = DMA_BIT_MASK(31);
 
 	/* Configure DMA attributes. */
 	if (dma_mask > DMA_BIT_MASK(32)) {
 		err = dma_set_mask(&pdev->dev, dma_mask);
 		if (!err) {
 			features |= NETIF_F_HIGHDMA;
-			err = dma_set_coherent_mask(&pdev->dev,
-						    persist_dma_mask);
+			if (!test_dma_mask ||
+			    dma_set_coherent_mask(&pdev->dev,
+						  test_dma_mask)) {
+				if (test_dma_mask)
+					dev_warn(&pdev->dev,
+						 "Unable to set 31 bit coherent DMA mask, workaround not applied\n");
+				err = dma_set_coherent_mask(&pdev->dev,
+							    persist_dma_mask);
+			}
 			if (err < 0) {
 				dev_err(&pdev->dev, "Unable to obtain 64 bit "
 					"DMA for consistent allocations\n");
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net v3 2/3] tg3: Skip management FW version when APE firmware is not ready
  2026-11-18 10:54 [PATCH net v3 0/3] tg3: Bug fixes Pavan Chebbi
  2026-11-18 10:52 ` netdev-bot+sinfo
  2026-11-18 10:54 ` [PATCH net v3 1/3] tg3: Don't fail probe if 31-bit coherent DMA mask is unsupported Pavan Chebbi
@ 2026-11-18 10:54 ` Pavan Chebbi
  2026-11-18 10:54 ` [PATCH net v3 3/3] tg3: Fix heap overflow in unbuffered NVRAM write path Pavan Chebbi
  3 siblings, 0 replies; 7+ messages in thread
From: Pavan Chebbi @ 2026-11-18 10:54 UTC (permalink / raw)
  To: michael.chan, kuba
  Cc: andrew+netdev, andrew.gospodarek, davem, edumazet, netdev, pabeni,
	Pavan Chebbi

When the APE firmware is not present or not ready, for example when
the NCSI component is missing in the NVRAM, tg3_read_fw_ver() still
calls tg3_read_dash_ver() after tg3_probe_ncsi().  The signature and
ready checks that tg3_read_dash_ver() used to make were moved into
tg3_probe_ncsi(), which only sets the NCSI flag and does not stop the
caller.  The driver then reads the APE firmware version register, which
holds no valid data in this state, and ethtool -i shows an invalid
"DASH" string with a garbage version.

Make tg3_probe_ncsi() return whether valid, ready APE firmware was
found, and read the version only in that case.  Otherwise just report
the bootcode version.

This was seen by a user on BCM5719/BCM5720 with no NCSI component in
the NVRAM.  With this change, ethtool -i displays only the bootcode
version.

Fixes: 165f4d1cb3d7 ("tg3: Fix the setting of the APE_HAS_NCSI flag")
Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
---
 drivers/net/ethernet/broadcom/tg3.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 2cf9d2ea069b..5a0e247a4c46 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -15997,20 +15997,26 @@ static void tg3_read_mgmtfw_ver(struct tg3 *tp)
 	}
 }
 
-static void tg3_probe_ncsi(struct tg3 *tp)
+/* Returns true if valid, ready APE firmware is present, regardless of
+ * whether it advertises NCSI (it may be DASH or SMASH).  Sets APE_HAS_NCSI
+ * if the NCSI feature is advertised.
+ */
+static bool tg3_probe_ncsi(struct tg3 *tp)
 {
 	u32 apedata;
 
 	apedata = tg3_ape_read32(tp, TG3_APE_SEG_SIG);
 	if (apedata != APE_SEG_SIG_MAGIC)
-		return;
+		return false;
 
 	apedata = tg3_ape_read32(tp, TG3_APE_FW_STATUS);
 	if (!(apedata & APE_FW_STATUS_READY))
-		return;
+		return false;
 
 	if (tg3_ape_read32(tp, TG3_APE_FW_FEATURES) & TG3_APE_FW_FEATURE_NCSI)
 		tg3_flag_set(tp, APE_HAS_NCSI);
+
+	return true;
 }
 
 static void tg3_read_dash_ver(struct tg3 *tp)
@@ -16089,8 +16095,7 @@ static void tg3_read_fw_ver(struct tg3 *tp)
 
 	if (tg3_flag(tp, ENABLE_ASF)) {
 		if (tg3_flag(tp, ENABLE_APE)) {
-			tg3_probe_ncsi(tp);
-			if (!vpd_vers)
+			if (tg3_probe_ncsi(tp) && !vpd_vers)
 				tg3_read_dash_ver(tp);
 		} else if (!vpd_vers) {
 			tg3_read_mgmtfw_ver(tp);
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net v3 3/3] tg3: Fix heap overflow in unbuffered NVRAM write path
  2026-11-18 10:54 [PATCH net v3 0/3] tg3: Bug fixes Pavan Chebbi
                   ` (2 preceding siblings ...)
  2026-11-18 10:54 ` [PATCH net v3 2/3] tg3: Skip management FW version when APE firmware is not ready Pavan Chebbi
@ 2026-11-18 10:54 ` Pavan Chebbi
  2026-11-22 11:07   ` netdev-bot+sashiko
  3 siblings, 1 reply; 7+ messages in thread
From: Pavan Chebbi @ 2026-11-18 10:54 UTC (permalink / raw)
  To: michael.chan, kuba
  Cc: andrew+netdev, andrew.gospodarek, davem, edumazet, netdev, pabeni,
	Shravya KN, Pavan Chebbi

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.  Without this, a write that spans more than one page
programmed every page after the first with the data of the first page,
and a write that did not start on a page boundary lost the tail of the
data without reporting an error.

Reject an nvram_pagesize that is smaller than 4 or not a power of two.
The page mask is pagesize - 1, which is only a valid mask for a power
of two.  A page size of 0, which tg3_get_nvram_info() leaves unset for
an unhandled flash vendor, also made the loop issue erase commands at
address 0 forever with the rtnl and NVRAM locks held.  ethtool -E now
fails with -EINVAL in these cases.

This was found by an AI code review scan.  It has not been observed on
hardware, but it can be reached with ethtool -E on devices with
unbuffered flash.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
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 | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 5a0e247a4c46..12f199355984 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -56,6 +56,7 @@
 #include <linux/hwmon-sysfs.h>
 #include <linux/crc32.h>
 #include <linux/dmi.h>
+#include <linux/log2.h>
 
 #include <net/checksum.h>
 #include <net/gso.h>
@@ -3379,6 +3380,9 @@ static int tg3_nvram_write_block_unbuffered(struct tg3 *tp, u32 offset, u32 len,
 	u32 nvram_cmd;
 	u8 *tmp;
 
+	if (pagesize < 4 || !is_power_of_2(pagesize))
+		return -EINVAL;
+
 	tmp = kmalloc(pagesize, GFP_KERNEL);
 	if (tmp == NULL)
 		return -ENOMEM;
@@ -3399,13 +3403,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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH net v3 1/3] tg3: Don't fail probe if 31-bit coherent DMA mask is unsupported
  2026-11-18 10:54 ` [PATCH net v3 1/3] tg3: Don't fail probe if 31-bit coherent DMA mask is unsupported Pavan Chebbi
@ 2026-11-22 11:07   ` netdev-bot+sashiko
  0 siblings, 0 replies; 7+ messages in thread
From: netdev-bot+sashiko @ 2026-11-22 11:07 UTC (permalink / raw)
  To: pavan.chebbi
  Cc: michael.chan, kuba, andrew+netdev, andrew.gospodarek, davem,
	edumazet, netdev, pabeni, shravya.k-n

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] On BCM57766, tg3_alloc_consistent()
  (drivers/net/ethernet/broadcom/tg3.c, around line 8870) can find that…

--

tg3: Don't fail probe if 31-bit coherent DMA mask is unsupported

This patch makes the 31-bit coherent DMA mask for BCM57766 best effort.
If the platform refuses that mask, the driver falls back to the coherent
mask used before 614f4d166eee, so probe no longer fails. It also adds a
warning when a status block is allocated at a DMA address that matches
the erratum pattern described in 614f4d166eee.

Link: https://lore.kernel.org/netdev/CALjTZvYKHWrD5m+RXimjxODvpFPw7Cq_EOEuzRi1PZT9_JxF+g@mail.gmail.com/

> diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
> index 95827df4cf6a1..2cf9d2ea069b5 100644
> --- a/drivers/net/ethernet/broadcom/tg3.c
> +++ b/drivers/net/ethernet/broadcom/tg3.c
> @@ -8867,6 +8867,13 @@ static int tg3_alloc_consistent(struct tg3 *tp)
>  		if (!tnapi->hw_status)
>  			goto err_out;
>  
> +		if (tg3_asic_rev(tp) == ASIC_REV_57766 &&
> +		    (lower_32_bits(tnapi->status_mapping) & 0xffff0000) ==
> +		    0xffff0000)
> +			dev_warn(&tp->pdev->dev,
> +				 "Status block at DMA address %pad may cause TX timeouts on this device\n",
> +				 &tnapi->status_mapping);
> +

[Severity: Low]
When the status block lands at an address that matches the erratum
pattern, the driver keeps the buffer. tg3_rings_reset() later writes
that address into the chip:

	tw32(HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_HIGH,
	     ((u64) tnapi->status_mapping >> 32));
	tw32(HOSTCC_STATUS_BLK_HOST_ADDR + TG3_64BIT_REG_LOW,
	     ((u64) tnapi->status_mapping & 0xffffffff));

tg3_alloc_consistent() is only called from tg3_start(). A recovery reset
therefore writes the same address again. That covers both the
tg3_process_error() "DMA Status error.  Resetting chip." path and a TX
timeout reset. Only closing and reopening the interface gets a new
allocation.

Could the driver hold on to the matching buffer and allocate a
replacement instead? That would keep the workaround in effect on
platforms that refuse the 31-bit mask.

The warning also gives TX timeouts as the symptom. 614f4d166eee says the
hardware sets the overflow bit in the DMA status register, and
tg3_process_error() would report that as a DMA status error.

Are TX timeouts the expected symptom here, or should the message also
mention the DMA status error?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118105408.1076095-1-pavan.chebbi%40broadcom.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net v3 3/3] tg3: Fix heap overflow in unbuffered NVRAM write path
  2026-11-18 10:54 ` [PATCH net v3 3/3] tg3: Fix heap overflow in unbuffered NVRAM write path Pavan Chebbi
@ 2026-11-22 11:07   ` netdev-bot+sashiko
  0 siblings, 0 replies; 7+ messages in thread
From: netdev-bot+sashiko @ 2026-11-22 11:07 UTC (permalink / raw)
  To: pavan.chebbi
  Cc: michael.chan, kuba, andrew+netdev, andrew.gospodarek, davem,
	edumazet, netdev, pabeni, shravya.k-n

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 (1) · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The new guard `if (pagesize < 4 || !is_power_of_2(pagesize))
  return -EINVAL;` in tg3_nvram_write_block_unbuffered()…

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the patch only
  partly closes it.

--

tg3: Fix heap overflow in unbuffered NVRAM write path

This patch changes tg3_nvram_write_block_unbuffered() to clamp the copy
size to the room left in the current page and to advance buf on each
iteration. It also rejects an nvram_pagesize that is smaller than 4 or
not a power of two, so ethtool -E fails with -EINVAL in those cases.

> diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
> index 5a0e247a4c463..12f199355984b 100644
> --- a/drivers/net/ethernet/broadcom/tg3.c
> +++ b/drivers/net/ethernet/broadcom/tg3.c

[ ... ]

> @@ -3379,6 +3380,9 @@ static int tg3_nvram_write_block_unbuffered(struct tg3 *tp, u32 offset, u32 len,
>  	u32 nvram_cmd;
>  	u8 *tmp;
>  
> +	if (pagesize < 4 || !is_power_of_2(pagesize))
> +		return -EINVAL;
> +

[Severity: Medium]
Will this check reject every NVRAM write on 5750/5780 boards that use SST
flash?

tg3_get_nvram_info() sets up the SST parts without NVRAM_BUFFERED:

drivers/net/ethernet/broadcom/tg3.c:tg3_get_nvram_info() {
    ...
		case FLASH_VENDOR_SST_SMALL:
		case FLASH_VENDOR_SST_LARGE:
			tp->nvram_jedecnum = JEDEC_SST;
			tp->nvram_pagesize = SST_25VF0X0_PAGE_SIZE;
			break;
    ...
}

The constant is defined in tg3.h as:

#define SST_25VF0X0_PAGE_SIZE		4098

FLASH is set from NVRAM_CFG1_FLASHIF_ENAB. Because of that,
tg3_nvram_write_block() sends these devices down the unbuffered path:

	if (tg3_flag(tp, NVRAM_BUFFERED) || !tg3_flag(tp, FLASH)) {
		ret = tg3_nvram_write_block_buffered(tp, offset, len,
			buf);
	} else {
		/* unbuffered writer */

is_power_of_2(4098) is false. So tg3_set_eeprom() -> tg3_nvram_write_block()
-> tg3_nvram_write_block_unbuffered() returns -EINVAL every time.

The value 4098 looks like a typo for 4096, since SST25VF0x0 parts use
4 KiB sectors. Before this patch these boards were already broken: pagemask
was 0x1001, and the read loop wrote 4 bytes at tmp + 4096 into a 4098 byte
buffer. The new check stops that overflow, but it does so by refusing the
write rather than fixing the page size.

The commit message says:

    A page size of 0, which tg3_get_nvram_info() leaves unset for
    an unhandled flash vendor, also made the loop issue erase commands at
    address 0 forever with the rtnl and NVRAM locks held.  ethtool -E now
    fails with -EINVAL in these cases.

It does not say that a flash vendor the driver supports now always fails.

Should SST_25VF0X0_PAGE_SIZE be changed to 4096 as part of this fix? If
not, could the commit message mention the SST case for maintainers and
stable backporters?

[Severity: High]
This is a pre-existing issue, not one introduced by this patch, but the
unset page size case named in the commit message is only partly covered.
The new check only exists in the unbuffered writer.
tg3_nvram_write_block_buffered() still divides by the page size without
checking it:

drivers/net/ethernet/broadcom/tg3.c:tg3_nvram_write_block_buffered() {
    ...
		page_off = offset % tp->nvram_pagesize;
    ...
}

tg3_nvram_write_block() takes this path whenever FLASH is clear.

The vendor switches in tg3_get_5755_nvram_info(), tg3_get_5787_nvram_info()
and tg3_get_5761_nvram_info() have no default case, and FLASH is only set
inside matched cases. tg3_get_nvram_info() on 5750/5780 class parts is the
same when NVRAM_CFG1_FLASHIF_ENAB is clear and the vendor does not match.
In all of these cases nvram_pagesize stays 0 and FLASH stays clear.

tg3_get_nvram_size() still sets nvram_size, so ethtool_set_eeprom() passes
its length checks. The call chain is then:

tg3_set_eeprom()
  tg3_nvram_write_block()
    tg3_nvram_write_block_buffered()
      offset % 0

Can this hit a divide error oops while rtnl and the NVRAM lock are held?
If so, would it make sense to do the same page size check in
tg3_nvram_write_block() so that both writers are covered?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261118105408.1076095-1-pavan.chebbi%40broadcom.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-11-22 11:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 10:54 [PATCH net v3 0/3] tg3: Bug fixes Pavan Chebbi
2026-11-18 10:52 ` netdev-bot+sinfo
2026-11-18 10:54 ` [PATCH net v3 1/3] tg3: Don't fail probe if 31-bit coherent DMA mask is unsupported Pavan Chebbi
2026-11-22 11:07   ` netdev-bot+sashiko
2026-11-18 10:54 ` [PATCH net v3 2/3] tg3: Skip management FW version when APE firmware is not ready Pavan Chebbi
2026-11-18 10:54 ` [PATCH net v3 3/3] tg3: Fix heap overflow in unbuffered NVRAM write path Pavan Chebbi
2026-11-22 11:07   ` netdev-bot+sashiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox