🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26638

Re: [PATCH net-next 4/4] e100: prevent shift-out-of-bounds in EEPROM access

#26638
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 01:07
201 lines
15712 bytes
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.
- [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
Technical Details
Message-ID: <179634647328.3146.11003408099329742694@kernel.org>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376945-linux-kernel-netdev=dewy.ru
References: <20261203005042.348952-5-anthony.l.nguyen@intel.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376945-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next 4/4] e100: prevent shift-out-of-bounds in EEPROM access
Date: Fri, 04 Dec 2026 01:07:53 +0000
Organization: Usenet Network
Message-ID: <179634647328.3146.11003408099329742694@kernel.org>
References: <20261203005042.348952-5-anthony.l.nguyen@intel.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2643823"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:q0NS2mQB4F83VnEMHIQZfJo74Bs= sha256:OUWd3l6Dq5tVH6yd/jPpPUMF7wL8JDpnyYVAufZ1fds=
	sha1:w9VYOteYpdcsW61Xnw2tVeboBfo= sha256:YHELuRDWK6WNW2bOJtgKmTCEJG4IE4hg/l5ruqRywIQ=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 56A2E117A94; Fri,  4 Dec 2026 04:08:19 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.639
X-Spam-Status: No, score=-3.639 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id EZHhkQ9hkfW7;
	Fri,  4 Dec 2026 04:08:16 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-376945-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id CDA5D117A99; Fri,  4 Dec 2026 04:08:07 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id DC59B21DD6; Fri,  4 Dec 2026 01:08:03 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796346475;
	b=HovOnWr8drWJAxPPa7KHDi5TUEz7Om+BG9M2+7BxI/I/495ZbZUMdgP60gv68rIFU9ZY
	 EyFDYOxHdz3IDh9I2LdX1jALUlFd8SM6HFNspoKWintQ+iW/nlIM/vykXqaOVbWRoHF5o
	 I6DyFLvEXMyHncYPJM1zYpSORw8fAt78sOVtvCOByiqm9rFF7ggrPYqWk702T/5pMcFHk
	 ZU3xXZ6EitsPKNkj1N5cgkEiWxXzBWsXCEjNkEPSfg/aIwovXYz/6hEJ60ejDAI+F8eCE
	 tQWnh8YLetlbaOOyRxJRJWLDC/Kp1iWqqMk2pB3Dz3U0oL46OW8lUUaKcTGSe5E4DOQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796346475;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=OFuG3VwpfhNV3BS8qlKTBw1AVwIaa+Zr/+nQflQiZNI=;
	b=iFUiw/g6feQjGmbh5Qkn1qc81SNggvezf8CjCwlI1ksfC6S2L7FOBB8hZVYqQC1BWVQY
	 vNHMg70oB5O24ELHzX/LkwdTgv0WsJU4vf8OlI8wKvmnJYTmeQt02jXpAzko4e1FkfxZh
	 pIXTQhJxp/PSHtyKU/H5cDfwLjXPBSCc7RYHGfHJ8V23mN+JTyRplvpyP473Y1/b1Qvs/
	 c5tuJ9uOtJETEeOm7qS6eh4BuDPv195gJw/SiskmoylcxDqDsibNBLwTja5to3EfyId/g
	 NG/IPwYEZIoZ/2QAx78+lYTA2zvK4Y5Esn90RbZR0vDbW85L7YbGyqgkkBn99frTrMg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Yi8LSmtk;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id A00D6606A33A;
	Fri,  4 Dec 2026 01:07:55 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Yi8LSmtk
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796346474;
	b=e/NSsRXiuSNN8ga3snRgD47vO7vWC9qiWV+LbbaqRvKmtcx3PM1EIZlOjGxrXMN6+kMg
	 d3rA8+7DSyocX8lat/WvAUH5dKRVKltv79O/LN8F+v12AYTNjPZeYaqToxo2VVrvBZNWR
	 mC/YGF3dBLB2UfJbD8zK7LitphwFcKPwnKVxzcn46KUJimxhiBxPTJGOB/AifsNTmadoe
	 L91yNVOEZ7KSlZ7AKYD4ZwGXRBCl62ox9GD91WBv9Vi0wo4RZliN+x/wV1RVBYih1kpSM
	 vx7VjF3ZFR3QPMKBRtKSqkNtelAsAaIoWRaILP9qDvYy1RGBOK4otJds6DW4WEBa1+Q==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796346474;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=OFuG3VwpfhNV3BS8qlKTBw1AVwIaa+Zr/+nQflQiZNI=;
	b=qMups+TIQHwugQmzxC3GImN+dUQ+V1JSpvpekditZtNyL85h4uPipKPLLsg6HwRmnG9G
	 ff4NdcVldGZdn2dA+k8eCJUOEDfLZalKKCp+X4/0BHiikv5qUHXsWRuwzWKcD+nR7H1in
	 Fg0L3oYUCP5PABnrrEZK9CcT9G3A08dAMCss1qubz9UaGSGyjsNPIZkL4n+N5/CtotXY0
	 EqIpzRR96Fmnzl/Kg0BChKNgdhVz9ppvnJEdAXn7J7VpKN0aFoq/sMQ8cPPzvVHGHSZ/a
	 N0PrXLaDflzEVCaW2FjkS49ekK9pdYqUL3Joobx+bhAzKBZYlkIcEqj9KlkoKT1C3Rg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Yi8LSmtk;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1EA4606A32C
	for <netdev@vger.kernel.org>; Fri,  4 Dec 2026 01:07:54 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id B29501F00897;
	Fri,  4 Dec 2026 01:07:53 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796346474;
	bh=OFuG3VwpfhNV3BS8qlKTBw1AVwIaa+Zr/+nQflQiZNI=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=Yi8LSmtkZXHgMYQgHTu/pEAIA/wzTW3enSB7PvpYESbTStKi3K2lUxpU/9Ziixpzd
	 ZedWNh0KETd+dnYUDjGfJgjx5RYOgaAbbwq5xgFTMbcmrHnVFZ338O0tkmjFGKAkdg
	 J6f1z3gX8eaEbO7LeBNrOKRGlOMjXBXyOU8nFGYSZluOYpswLtdEUx5M8q1oSRUBuU
	 G7wdWNWp7TIEUNE0ikvYod1zSyJR3h30gCc0kXWlE8LFPv+5de7Ytxt9CGdY3gxy39
	 ipapZexZKFKgnBltwRUEwKSunmOfMLVbrBd8f4epyrjNfWE0sXCv5L7i+oqCppdVkx
	 XNuOSyjQWQQcA==
X-Cc: 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,
 pavankumaryalagada@gmail.com, sx.rinitha@intel.com
X-In-Reply-To: <20261203005042.348952-5-anthony.l.nguyen@intel.com>
X-sashiko-severity: High
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list