From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.171 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796468948; b=RkQ9QT7QMKTPIsOi9AgAg4bklBTYl3Sor90wSXlIAzVxKyxM4ql1XRad1CsvjXxHnVzS byEWHtzdROIsYaXdKeAayXnwksOjSW35Atl1Jn1MhIxDkcG2FnvP8jfxmFyAc3aOgU32Z 0PE4Nv11jmJsMy2AOctpzZc68WLGIlyTLk2ZGF6X9XLsGHRck0hM9hRUWc2cG4hgoUSr6 /0Zjvj63UYCWSXrVcU5G2onzi58yA0iPwUjqCpZ4Dd5wgS/XH+jhKV2gZ5gy5EgLPz2v0 wJNlwcwlfhiFDIJBmo13Y9CTxGyOiFdES7JGo7iZv+4J89ml5zKIidRRQqSTaKeoPIQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796468948; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:Content-Transfer-Encoding: In-Reply-To; bh=CViVGYa3+WEwSP2/Ciw8PCnMu9PIEsU1LIR5Ot4HpHA=; b=sRWG9n5aoP67YFYt+Ig25PCljkNWnjHpPOwGmR0/sqLFTRCyhOw0WWVer2eSUmA73j0r fVLliPAcknEM8NIVmWcrxRTJrDAki3FUdY1FMVkePF0xS0hspP9YB6zMOG77yGpCRyuzD A7qEGsb9utEXUqQEH6SAm5h+8+JAKVsDpyKGiOwXZovN5JRAzU2j2IGa6dSeJ57WnsLBI 0Y0hcD2ZgbNwTzV0xFxFYnCW9Yfqcl/6PwgP3mnCb5w3ZfryXIzJlmZyAv5cCT0nJ4HcA VQSTC3bE0Mjvy6yQLeCVG9B+QXL6kJ/riQLi0aS7Z1CWqhnS2qHdnKLq4om0Oknx+ag== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=qd0e0eJY; arc=none smtp.remote-ip=74.125.82.171 Received: from mail-dy1-f171.google.com (mail-dy1-f171.google.com [74.125.82.171]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BDAE1606A338 for ; Sat, 5 Dec 2026 11:09:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BDAE1606A338 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=qd0e0eJY Received: by mail-dy1-f171.google.com with SMTP id 5a478bee46e88-3282db206d3so332990eec.0 for ; Sat, 05 Dec 2026 03:09:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796468947; x=1797073747; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=CViVGYa3+WEwSP2/Ciw8PCnMu9PIEsU1LIR5Ot4HpHA=; b=qd0e0eJY683arjeofYJqXyDj9Mi0qI6AWCUeSQZScwi/ZUjRsfzpGh42taGQsVyDtg 0TtO+n+ZY8gSncpMLwKeg9NxWv3D07BuB3flGnCW/eFV6fVhyQ+h5PWz8cddLZiORQ2i ijA8/ZMbS4A9YqrtD0fQtVu2fi2/KIXS5eso767xldOoDu3IeFMIWEceZNac0KeHX3Jy +iauvdKRQXQ+vcBUQFjuQGt4Mo8SWfZzmehk+e4jvFPtM1gln5RAuZg5E9dhTvqMI93u MM/hl8L39B6+wy61XgPpiY1PnfwDRMFzp4iRlLFKFStOsBYR4AqofPevDUBNGs8GNh8O 9ZxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796468947; x=1797073747; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=CViVGYa3+WEwSP2/Ciw8PCnMu9PIEsU1LIR5Ot4HpHA=; b=WyG95HLjyZ6mYfUOtC/gwTDKzaYSvb1/BNz5QtvEGhn0ZIZ+u+rW2r3TpbIHo8Kwsi zncd7Cr1Nrhw/jMgSo7BcIWcOetSlQBTVi8JDU06DLlPhvUga8fiTEsBg85jE0JN3n3T 0H0lSat4QQohGu/aNacht1zNgM7PbMaqoOtk8r+O77gZW0ZuqPLQBD0Tlb4B71PREEUE dK/gW+yrTi7ns6vgn2xE+nwlosLcQrfo/HFRvCRFfYXgbTx6GKrPXu3P1f7sHh06MWWT 3TAy3oq8n6SOjww9wk+txJz2+901V/NHXB8oieczEaZbMBWiVV82E53MNI+ZFdRp8TqA 1BSA== X-Forwarded-Encrypted: i=1; AL+hErH+Zy9/xQ26fk46klf2q64bOa+pf/c0N1pmA5MAbzmUPh8VrdfpfE4OeSX7nYiUBkji68+OZkI=@vger.kernel.org X-Gm-Message-State: AB4q+uHJojBnR/CNzWboht8vqbnFqDXHDRwX/2NwDgn8WQzqLqt87DFJ sB8RyQhfjzfnpB/ZCtSQDvUKAtzQfXZR2DKOAlGEHTYiX3lwaMqnfkNtTCC/sDBu X-Gm-Gg: AZFdTZdGFzZA9VhkUaX6Qx0G1ss2ejYgD4WHWDRBzsD21FM2zAD8/7WrLriEOKZRCaZ /Xu9eGHp289f6OswiufsEtZKZNWfh5hlo8XDnN2vlLzU6v7TuS0P/lYWXwFq8Yzmky694Jp1lCy cKWNcRNGiWIgatd/6YhBpawndCVW/2keci4/VL/4yDzL7vEQctofgQta9f94uft2Mxlv+T39IFs Ayp0kf+iKugXi85FsMGYKsw/PnY9oMpbOsjwOPkOBS+kET5Nw65ZM5I8M6gOnEi34dyeWuCqRDO 8eSHWbPGBiTHKr2HWllVzcTVmBQzfUklthVpb8mmNWsQSgInuKBBsCSA7nPr5cOFMYvUsRpKEff 8hud4knJF5U/YNCQ2CBuQ8XYPXCf+16ep11Tyr6kFcdC8zjhCsvaMPTjIkHFZOnOSBma2r0XhUW itN9GUSSpYH8bNTeO7/if4L0jXuBO7RHExokerPsMrddcGewfFOcfxQCWL3jvKfx3o3DQ3Bk6dH wVk+pwH/hP1YcJXsPW6hL5N9dO8qWdHPXUluthxK0aijlDDDqttBiCpxZ3zrND+UuGLiux37Gz/ vGQYhWg6uGADnvk1zU7v1KROzZeokTO7 X-Received: by 2002:a05:693c:864e:10b0:386:ebc5:4747 with SMTP id 5a478bee46e88-387520dbf49mr5460931eec.11.1796468946820; Sat, 05 Dec 2026 03:09:06 -0800 (PST) Received: from user ([2405:201:c052:b08b:8ac3:cdea:8a9e:687]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3875224895asm17980025eec.27.2026.12.05.03.09.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 03:09:06 -0800 (PST) Date: Sat, 5 Dec 2026 16:38:37 +0530 From: Yalagada Pavan Kumar 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 Message-ID: References: <20261203005042.348952-5-anthony.l.nguyen@intel.com> <179634647328.3146.11003408099329742694@kernel.org> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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