Netdev List
 help / color / mirror / Atom feed
From: Yalagada Pavan Kumar <pavankumaryalagada@gmail.com>
To: netdev-bot+sashiko@kernel.org
Cc: anthony.l.nguyen@intel.com, davem@davemloft.net, kuba@kernel.org,
	pabeni@redhat.com, edumazet@kernel.org, andrew+netdev@lunn.ch,
	willemb@google.com, netdev@vger.kernel.org,
	paweldembicki@gmail.com, dima.ruinskiy@intel.com,
	sx.rinitha@intel.com
Subject: Re: [PATCH net-next 4/4] e100: prevent shift-out-of-bounds in EEPROM access
Date: Sat, 5 Dec 2026 16:38:37 +0530	[thread overview]
Message-ID: <axPwtXzpEMdQf07J@user> (raw)
In-Reply-To: <179634647328.3146.11003408099329742694@kernel.org>

On Fri, Dec 04, 2026 at 01:07:53AM +0000, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 5 potential
> issue(s) to consider.
> 
> Critical: 0 · High: 1 · Medium: 1 · Low: 3 (1)
> 
> 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).
> 
> - [High] The new validation in e100_eeprom_load() and e100_eeprom_save()
>   only rejects addr_len == 0 or addr_len > 8.
> - [Medium] The patch checks addr_len only once, after the discovery read.
> - [Low] This fixes a syzbot-reported bug in e100_eeprom_load() that
>   predates git, but the commit has no Fixes: tag and no stable Cc.

I'll follow Andrew's suggestion from the other patch and drop the Fixes: tag.

I'll also address the reported issues and send a revised version of the
patch.

pw-bot: cr

> - [Low] This is an undisclosed behaviour change.
> - [Low] The new error in e100_eeprom_save() is logged with netif_err(nic,
>   probe, ...), which uses the NETIF_MSG_PROBE class.
> 
> Pre-existing issues:
> - [Low] This problem wasn't introduced by this patch, but
>   e100_set_eeprom() memcpys user data into the nic->eeprom cache (line…
> 
> --
> 
> e100: prevent shift-out-of-bounds in EEPROM access
> 
> This patch guards the addr_len adjustment in e100_eeprom_read() so it can
> no longer underflow. It also adds addr_len validation to
> e100_eeprom_load() and e100_eeprom_save(), which return -EIO when addr_len
> is zero or above 8. It addresses a syzbot-reported shift-out-of-bounds when
> computing eeprom_wc.
> 
> Closes: https://syzkaller.appspot.com/bug?extid=e0abb1d45ac291ebebeb
> 
> > When reading the EEPROM address length, e100_eeprom_read() can return
> > an invalid length. This value is then used as a shift count when
> > calculating eeprom_wc, resulting in a shift-out-of-bounds UBSAN warning.
> 
> [Severity: Low]
> Is the shift warning the whole of the old problem? Before this patch, if
> EEDO read low at i == 31, the old code did:
> 
> 	*addr_len -= (i - 16);
> 
> This wraps the u16 to 65529. On x86 and arm64 the masked 1 << addr_len
> then gives eeprom_wc == 0. The checksum compare in e100_eeprom_load() then
> indexes out of bounds:
> 
> 	if (cpu_to_le16(0xBABA - checksum) != nic->eeprom[nic->eeprom_wc - 1]) {
> 
> That is nic->eeprom[-1]. Later e100_eeprom_read() calls also shift
> op_read << *addr_len by a huge count.
> 
> Could the commit message mention the out-of-bounds index? This fixes a
> syzbot-reported bug that predates git, so should it also carry a tag like
> this, plus a Cc to stable?
> 
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> 
> > diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
> > index 29960762e64a8..cd81903866521 100644
> > --- a/drivers/net/ethernet/intel/e100.c
> > +++ b/drivers/net/ethernet/intel/e100.c
> 
> [ ... ]
> 
> > @@ -765,7 +772,15 @@ static int e100_eeprom_load(struct nic *nic)
> >  
> >  	/* Try reading with an 8-bit addr len to discover actual addr len */
> >  	e100_eeprom_read(nic, &addr_len, 0);
> > -	nic->eeprom_wc = 1 << addr_len;
> > +
> > +	if (!addr_len || addr_len > 8) {
> > +		netif_err(nic, probe, nic->netdev,
> > +			  "Invalid EEPROM address length %u\n",
> > +			  addr_len);
> > +		return -EIO;
> > +	}
> 
> [Severity: Low]
> Is this behaviour change intended? Take a board whose EEPROM is dead or
> unresponsive, so EEDO reads low on the first clock.
> 
> Before this patch, addr_len wrapped and eeprom_wc became 0 on x86 and
> arm64. The checksum compare failed, but with eeprom_bad_csum_allow=1
> e100_eeprom_load() still returned 0. e100_probe() then carried on and
> reported an invalid MAC address from the EEPROM.
> 
> With this patch, e100_eeprom_read() computes len = 15, which is greater
> than 8, so it sets addr_len = 0. e100_eeprom_load() then returns -EIO
> before the eeprom_bad_csum_allow check is reached, and e100_probe() fails
> whatever the module parameter says.
> 
> Could the commit message say that eeprom_bad_csum_allow no longer helps
> these boards?
> 
> > +
> > +	nic->eeprom_wc = (u16)BIT(addr_len);
> >  
> >  	for (addr = 0; addr < nic->eeprom_wc; addr++) {
> >  		nic->eeprom[addr] = e100_eeprom_read(nic, &addr_len, addr);
> 
> [Severity: Medium]
> addr_len is only validated once, after the discovery read. What happens if
> one of these per-word reads sees EEDO low at i >= 25?
> 
> The new break path in e100_eeprom_read() sets *addr_len = 0. It then
> returns data that holds only command-phase EEDO samples, with no failure
> signal. That value is stored in nic->eeprom[addr] as if it were a real
> word.
> 
> The rest of the loop then runs with addr_len == 0, while eeprom_wc stays
> at 256. In that state this line puts the address bits on top of the start
> bit and opcode:
> 
> 	cmd_addr_data = ((op_read << *addr_len) | addr) << 16;
> 
> For addr 0x98 the frame is 0x9E << 16, which the chip sees as 1 00 11
> (EWEN). Addresses 0xA0-0xBF encode 1 01 (WRITE), and 0xE0-0xFF encode
> 1 11 (ERASE).
> 
> Depending on how the EEPROM handles these frames, can a read-only load
> enable writes and then erase or overwrite EEPROM cells? Would it be safer
> to check addr_len inside this loop and return -EIO if it changes?
> 
> > @@ -791,7 +806,15 @@ static int e100_eeprom_save(struct nic *nic, u16 start, u16 count)
> >  
> >  	/* Try reading with an 8-bit addr len to discover actual addr len */
> >  	e100_eeprom_read(nic, &addr_len, 0);
> > -	nic->eeprom_wc = 1 << addr_len;
> > +
> > +	if (!addr_len || addr_len > 8) {
> 
> [Severity: High]
> Can an addr_len that this check accepts still cause a shift-out-of-bounds?
> addr_len starts at 8 and only decreases, so addr_len > 8 can never be
> true, and values 1 to 7 are accepted.
> 
> Suppose EEDO first reads 0 at i == 23 during the discovery read. Then
> len = 7, the new len > *addr_len guard in e100_eeprom_read() does not
> fire, and addr_len becomes 1. eeprom_wc is then BIT(1) = 2.
> 
> A later ethtool -E with offset 0 and len 1 then goes:
> 
> e100_set_eeprom()
>   e100_eeprom_save(nic, 0, 1)
>     start + count >= eeprom_wc    /* 1 >= 2, false */
>     e100_eeprom_write(nic, 1, ...)
> 
> and e100_eeprom_write() does:
> 
> 	cmd_addr_data[0] = op_ewen << (addr_len - 2);
> 	...
> 	cmd_addr_data[2] = op_ewds << (addr_len - 2);
> 
> After integer promotion, that is a shift by -1. On x86 the masked shift
> also turns EWEN into an EWDS-like frame and sends no EWDS frame at all.
> The write then fails silently while e100_eeprom_save() returns 0.
> 
> e100_eeprom_load() has the same check, so probe can succeed with
> eeprom_wc == 2. That happens if the 2-word checksum matches or if
> eeprom_bad_csum_allow=1 is set.
> 
> 8255x Microwire EEPROMs use only 6 or 8 address bits. Should both checks
> require addr_len to be 6 or 8, or at least addr_len >= 2?
> 
> > +		netif_err(nic, probe, nic->netdev,
> > +			  "Invalid EEPROM address length %u\n",
> > +			  addr_len);
> 
> [Severity: Low]
> This isn't a bug, but e100_eeprom_save() is only called from the ethtool
> callback e100_set_eeprom(), never from probe. Should this use the hw or
> drv message class instead of probe? With probe, the error is hidden when
> probe messages are disabled.
> 
> > +		return -EIO;
> 
> [Severity: Low]
> This is a pre-existing issue and was not introduced by this patch.
> e100_set_eeprom() copies the user data into the cache before it calls
> e100_eeprom_save():
> 
> 	memcpy(&((u8 *)nic->eeprom)[eeprom->offset], bytes, eeprom->len);
> 
> 	return e100_eeprom_save(nic, eeprom->offset >> 1,
> 		(eeprom->len >> 1) + 1);
> 
> If e100_eeprom_save() fails early, the cache keeps the rejected bytes.
> That covers this new -EIO and the existing -EINVAL. e100_get_eeprom() then
> reports those bytes as EEPROM contents.
> 
> Before this patch, an invalid addr_len took the -EINVAL path with the same
> result, so this patch does not make it any worse. Should the cache change
> be rolled back when e100_eeprom_save() fails?
> 
> -- 
> Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203005042.348952-1-anthony.l.nguyen%40intel.com

  reply	other threads:[~2026-12-05 11:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  0:50 [PATCH net-next 0/4][pull request] Intel Wired LAN Driver Updates 2026-12-02 (igc, igb, e100) Tony Nguyen
2026-12-03  0:50 ` [PATCH net-next 1/4] igc: Support ACPI-based MAC passthrough Tony Nguyen
2026-12-04  1:07   ` netdev-bot+sashiko
2026-12-04  1:28     ` Andrew Lunn
2026-12-03  0:50 ` [PATCH net-next 2/4] igb: detect M88E1112 100BASE-FX SGMII mode Tony Nguyen
2026-12-04  1:07   ` netdev-bot+sashiko
2026-12-03  0:50 ` [PATCH net-next 3/4] igb: read SFP module EEPROM through igb_read_sfp_data_byte Tony Nguyen
2026-12-04  1:07   ` netdev-bot+sashiko
2026-12-03  0:50 ` [PATCH net-next 4/4] e100: prevent shift-out-of-bounds in EEPROM access Tony Nguyen
2026-12-04  1:07   ` netdev-bot+sashiko
2026-12-05 11:08     ` Yalagada Pavan Kumar [this message]
2026-12-03  0:53 ` [PATCH net-next 0/4][pull request] Intel Wired LAN Driver Updates 2026-12-02 (igc, igb, e100) netdev-bot+sinfo

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=axPwtXzpEMdQf07J@user \
    --to=pavankumaryalagada@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=anthony.l.nguyen@intel.com \
    --cc=davem@davemloft.net \
    --cc=dima.ruinskiy@intel.com \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev-bot+sashiko@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=paweldembicki@gmail.com \
    --cc=sx.rinitha@intel.com \
    --cc=willemb@google.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