Article View: linux.kernel.netdev
Article #9354Re: [PATCH net v2 2/5] net: dsa: b53: fix the SRAB grant timeout check
From: netdev-bot+sashiko
Date: Sun, 01 Nov 2026 21:46
Date: Sun, 01 Nov 2026 21:46
120 lines
11865 bytes
11865 bytes
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] The grant poll loop in b53_srab_request_grant()
(drivers/net/dsa/b53/b53_srab.c, lines 102-109) wastes its final sleep.
Pre-existing issues:
- [Medium] Uninitialized stack values are used on the grant-timeout path
that this patch makes reachable.
--
net: dsa: b53: fix the SRAB grant timeout check
This patch changes the timeout check in b53_srab_request_grant() from
i == 5 to i == 20 so that it matches the 20 iteration poll loop. A grant
that never arrives now returns -EIO, where before the register access
went ahead without ownership of the switch resources.
> diff --git a/drivers/net/dsa/b53/b53_srab.c b/drivers/net/dsa/b53/b53_srab.c
> index 83a03fca142a0..f4689078ccd51 100644
> --- a/drivers/net/dsa/b53/b53_srab.c
> +++ b/drivers/net/dsa/b53/b53_srab.c
> @@ -105,7 +105,7 @@ static int b53_srab_request_grant(struct b53_device *dev)
> break;
> usleep_range(10, 100);
> }
> - if (WARN_ON(i == 5))
> + if (WARN_ON(i == 20))
> return -EIO;
[Severity: Medium]
This is a pre-existing issue, but this patch makes the grant timeout
path reachable. Several callers then use uninitialized values.
When b53_srab_request_grant() returns -EIO, b53_srab_read8() (and the
read16/read32/read48/read64 variants) skip the *val assignment:
drivers/net/dsa/b53/b53_srab.c:b53_srab_read8() {
ret = b53_srab_request_grant(dev);
if (ret)
goto err;
...
*val = readl(regs + B53_SRAB_RD_L) & 0xff;
err:
b53_srab_release_grant(dev);
...
}
The b53_build_op() wrappers in b53_priv.h pass the error through and do
not initialize *val. Many callers in b53_common.c ignore the return
value. One example is b53_get_ethtool_stats():
} else {
u32 val32;
b53_read32(dev, B53_MIB_PAGE(port), s->offset,
&val32);
val = val32;
}
data[i] = (u64)val;
Can this copy uninitialized kernel stack data into the ETHTOOL_GSTATS
buffer that is returned to userspace?
Other callers follow the same pattern:
b53_eee_enable_set() writes an uninitialized u16 reg back to
B53_EEE_EN_CTRL with b53_write16().
b53_enable_vlan() read-modify-writes the uninitialized mgmt, vc0, vc1
and vc5 into the switch mode and VLAN control registers.
b53_arl_search_read_89() (and the _25/_63xx/_95 variants) decode the
uninitialized mac_vid and fwd_entry into a b53_arl_entry.
b53_fdb_dump() then passes that entry to b53_fdb_copy() and the FDB
dump callback.
Before this patch, a grant timeout fell through to b53_srab_op() and
*val got written. The same uninitialized use could already happen
through the GORDYN timeout in b53_srab_op(). That path also returns
-EIO and skips the assignment.
Should the SRAB read accessors zero *val on error? The other option is
for these callers to check the b53_read*() return value.
[Severity: Low]
Can this reject a grant that arrives during the last sleep?
On the i == 19 iteration, the loop reads B53_SRAB_CTRLS and sees no
RCAGNT. It then calls usleep_range(10, 100) and exits with i == 20,
without reading CTRLS again:
for (i = 0; i < 20; i++) {
ctrls = readl(regs + B53_SRAB_CTRLS);
if (ctrls & B53_SRAB_CTRLS_RCAGNT)
break;
usleep_range(10, 100);
}
Suppose the arbiter asserts RCAGNT during that last sleep. The function
now WARNs and returns -EIO. The caller's err: path then calls
b53_srab_release_grant() and clears RCAREQ, even though access was
granted. In practice the wait covers 19 polls, not 20.
Before this patch the timeout check never fired, so this had no effect.
Would readl_poll_timeout() avoid this? A final read of CTRLS after the
loop would also work.
>
> return 0;
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261028212310.3847553-1-florian.fainelli%40broadcom.com
Technical Details
Message-ID:
<179356961718.3131.9184132538995521305@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-354338-linux-kernel-netdev=dewy.ruReferences:
<20261028212310.3847553-3-florian.fainelli@broadcom.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-354338-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v2 2/5] net: dsa: b53: fix the SRAB grant timeout check Date: Sun, 01 Nov 2026 21:46:57 +0000 Organization: Usenet Network Message-ID: <179356961718.3131.9184132538995521305@kernel.org> References: <20261028212310.3847553-3-florian.fainelli@broadcom.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2777223"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:Nqw4KZMVe/XuZjvpbYqMOUgvojY= sha256:wrn2gmZ7/yDXJkoCUkHnPwqCVuxcBppyqg288tPlD40= sha1:SD2jYIZtg3NZx2bqZOJ+uCaJkvo= sha256:48W/TUV6gBxKhov9GpTjADlHOVzX7tihEtqbX7CEUGE= 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 B131B112039; Mon, 2 Nov 2026 00:47:18 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, 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 DJ49AphCpJXS; Mon, 2 Nov 2026 00:47:15 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-354338-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 5473611202F; Mon, 2 Nov 2026 00:47:06 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 3273326A4B; Sun, 1 Nov 2026 21:47:00 +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=1793569620; b=h4yBOLe+Q4gALeFgEfGR/lIXzc2PMBuiCtgmWoSXaTcBs5oityUv7UZjb7QjGc+LzyL5 NvUeZjFc0QyoZ+VO0DckwlvBpaA1ouVtoTc5cuHMU7t5nNQLaSHvKjrlNn5+Fkaplkxw7 P0tkg/kIwgXppWXGiJ4jCxhBxCkhuwoeElRw6ylnJEgOMnSUwvXiJvoncenfhxnovVHva EUy6Rx0emQNvrKw1oRiNGBp/Y9uf63BdYoSJDL9nWKn4Mbu4TKWwRNXROGQnBn4dEduuo 3uaWq3Br+yqwBQVqiYWr3NHu7UE1fitjcbfqpbEDzDT1Xj9kCZqCNmWOB/UR6Ressdw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793569620; 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=HHNSKT8SiXWz70ors39uBUGFQtreIPGuQljyrwy05Bw=; b=iwuQH0RQH0WDtb9PW8QYazZxj+m/1+wzrbd0RYz0M3048AuPSeetwGC4iwRgOj0dYsb/ oGj/DgAlP6HGsbogVfWZBu2dw8rWLJK2m2vwylmx2NMuPtiQpBv+L7SvL+iPLxNLYyW3E M3ZYIEX+BlAWi5x++HyrdSZpKDcHfcHKJrC93mfZVh3dQT7AbMYSt0p58+YQXt25WP/RF qd4sSBPcofkhQx53Qz0l33XZpi6mGZaPNz7cpm/zy+WOMUv9aMnhGKPfJftTmNBpjDCfv XDcapOQGNY2wSMBDctHZqc1Tkyy1jnRSf+ZHsCxnRyD+PYsY+FVUg5VaWx968DUkV1A== 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=EEXFL+K7; 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 07196606A32F; Sun, 1 Nov 2026 21:47:00 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=EEXFL+K7 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=1793569619; b=4COJnXopxQZZw2m3SnUnI/NPyenViXHV1JzFM5rsHn4sSC6iT4IpNNN3RW8kXQho+Lux VhK6UYazPJN/ZBcwqpWD+jix6PPGysebd+0HmKX37L3jh4MjepP0N+IsKY92iF8ZR/yEp 8ycMrbBVvlBAME4YzbM+v6hJNW+Kw9NvG693DnjHoNXOEBenaoDcgDpuJpQ1urG6nOLsW Rs7jc7YCSoP/NuE7aC/e36CdLvMN/HOZ4KevEm3vuhtc3oL8xI9dLQths0SS7sLkc2AT0 IcAP57Xig+UvfVOY4mZGGlgA2HA1s2Jod8osKtRPghquduup7mVYWg5q+la18CFY/BA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793569619; 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=HHNSKT8SiXWz70ors39uBUGFQtreIPGuQljyrwy05Bw=; b=vRqMuxOXRa1ayfQDO0TyfzL+niUKM+OyZmml8KfhFBVKmmeeWcgTTjKJ81uxGpnsCg0O LR/sxo4a18b/SLYAV/2jYEWAMs0Be6+l/j7elQSs1Iy0Awpvh86300ud/hs64zP3SQtIy 6JEExZSKYeTwlj3wOgv0WAF7vTHfXbI90YoCvJ4tu1NvBgDPPEDk3HfupayRtkVmp+rz4 ywJ/IvEZ/QhkfjJ6J8i4Iz3yHPT+MGwCjJnD+oPyXPsE9tXdx+6e1jOvnil7QCxUXup6M Z1DhENs9VADletatAG1dNeRrqSC6RWTpsjeIAUMSg3HWpDouwj7KyC5OgVU7/pOJ2mw== 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=EEXFL+K7; 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 C3E1D606A324; Sun, 1 Nov 2026 21:46:58 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9E451F000C1; Sun, 1 Nov 2026 21:46:57 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793569618; bh=HHNSKT8SiXWz70ors39uBUGFQtreIPGuQljyrwy05Bw=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=EEXFL+K7EjhxWxcm506v37hbdH3npV09OKDxBP4TGzf42EIM4SOsIAOtFf+/4mq+U Xy4yU3bVERLS12Fe52vrQbCZGWmxJ/NJ4/QLLRyEyvpVbp1HC321Mk0FYiKHjbUu9D Tuvf3IthneoNzcWXFIz1of9DXJ6sEqmcjDlzywVKYhiYSq0J7CvQNJC4GMMD7pQ6Hg whGLSLSSDdLbTU4+SRzD6P85UqctuWmE4ntHLkXBd7CRFtjz63QTdT7jR0IOQQuPyR g5I79JwgQyqCMrrHynr/X6vuberIeLj0FGVe/+r5KgjJprepxEV2nI7kUrNYyCmRX/ 85LxxZ9Iak1Kw== X-Cc: netdev@vger.kernel.org, jonas.gorski@gmail.com, andrew@lunn.ch, olteanv@gmail.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, linux@armlinux.org.uk, rmk+kernel@armlinux.org.uk, linux-kernel@vger.kernel.org X-In-Reply-To: <20261028212310.3847553-3-florian.fainelli@broadcom.com> X-sashiko-severity: Low 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