Article View: linux.kernel.netdev
Article #20894Re: [PATCH net] net/ncsi: fix channel loop termination when Channel Count is 0
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 10:28
Date: Mon, 23 Nov 2026 10:28
146 lines
13268 bytes
13268 bytes
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 commit message says that "With the patch, Channel Count 0
behaves exactly like Channel Count 1" and that the probe-path change…
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the patch's
own reasoning depends on it: the commit message says "Fixing the loop…
--
net/ncsi: fix channel loop termination when Channel Count is 0
This patch changes the termination checks of the channel walks in
ncsi_suspend_channel() and ncsi_probe_channel() from "==" to ">=". The
goal is that a controller reporting Channel Count 0 in its Get
Capabilities response can no longer make the walks run past the reported
count. The suspend_gls change fixes a hang seen after a link-down AEN.
> diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c
> index 1d63958c4429b..c5cf2ca0385c1 100644
> --- a/net/ncsi/ncsi-manage.c
> +++ b/net/ncsi/ncsi-manage.c
[ ... ]
> @@ -1491,7 +1491,7 @@ static void ncsi_probe_channel(struct ncsi_dev_priv *ndp)
> ndp->channel_probe_id++;
> }
>
> - if (ndp->channel_probe_id == ndp->channel_count) {
> + if (ndp->channel_probe_id >= ndp->channel_count) {
> ndp->channel_probe_id = 0;
> nd->state = ncsi_dev_state_probe_dp;
> }
[Severity: High]
This is a pre-existing issue, not one introduced by this patch. The
commit message says:
Fixing the loop bounds handles any reported value where it is used
Does that hold for large counts? ncsi_rsp_handler_gc() still stores the
8-bit Channel Count with no upper bound:
net/ncsi/ncsi-rsp.c:ncsi_rsp_handler_gc() {
...
np->ndp->channel_count = rsp->channel_cnt;
...
}
A controller can report a count from 33 to 255. Both this probe loop and
the suspend_gls state in ncsi_suspend_channel() then send commands with
nca.channel = channel_probe_id, up to channel 254.
ncsi_cmd_build_header() does not mask the channel:
#define NCSI_TO_CHANNEL(p, c) (((p) << NCSI_PACKAGE_SHIFT) | (c))
So channel 31 becomes the reserved package-level channel. On package 0,
channel 32 goes out as 0x20, which is package 1, channel 0.
A channel that does not answer does not stop the walk.
ncsi_request_timeout()->ncsi_free_request() schedules the work again and
probing continues.
Suppose a second package, or an emulator that echoes the channel byte,
answers the CIS sent to 0x20. Package 1 has not been added yet, because
that only happens in ncsi_rsp_handler_sp(). So
ncsi_find_package_and_channel() returns np == NULL and nc == NULL:
net/ncsi/ncsi-rsp.c:ncsi_rsp_handler_cis() {
...
ncsi_find_package_and_channel(ndp, rsp->rsp.common.channel, &np, &nc);
if (!nc) {
if (ndp->flags & NCSI_DEV_PROBED)
return -ENXIO;
id = NCSI_CHANNEL_INDEX(rsp->rsp.common.channel);
nc = ncsi_add_channel(np, id);
}
...
}
NCSI_DEV_PROBED is still clear during probe. Can ncsi_add_channel() then
oops on spin_lock_irqsave(&np->lock, flags) in the NET_RX softirq?
The old "==" check produced the same aliasing for these counts. Would it
help to clamp channel_cnt in ncsi_rsp_handler_gc() to the range 1 to
NCSI_MAX_CHANNEL - 1, and to add an np NULL check in
ncsi_rsp_handler_cis()?
[Severity: Medium]
The commit message says:
With the patch, Channel Count 0 behaves exactly like Channel Count 1
(same command counts); Channel Count 1 is unchanged.
It also says the probe path change "removes the ordering dependency".
Is that true for ncsi_probe_channel()?
This check runs after every CIS/GVI/GC/GLS step. It compares against
ndp->channel_count, which is a single device-wide value.
ncsi_register_dev() sets it to NCSI_RESERVED_CHANNEL once. After that,
only ncsi_rsp_handler_gc() writes it, and it is never reset between
packages.
Take a single package that reports 0. If the GC response is processed
before the check that follows the GC command, as in the tests described
above, the check sees 0 >= 0. The state then moves to probe_dp and GLS is
never sent to channel 0.
If the response arrives later, GLS is sent. With a count of 1, GLS is
always sent. So with a count of 0, the result still depends on response
timing.
Now take multiple packages, where package N reports 0. The probe of
package N+1 sends CIS to channel 0 and hits the check right away:
ncsi_dev_state_probe_cis:
send CIS to channel 0
nd->state = ncsi_dev_state_probe_gvi
channel_probe_id (0) >= channel_count (0)
nd->state = ncsi_dev_state_probe_dp
GVI, GC and GLS are never sent to package N+1 channel 0. Its caps,
version and link state stay at zero, and its other channels are not
probed. The zero caps could also make ncsi_check_hwa() treat the device
as not supporting HWA.
"==" behaves the same way in both of these cases, so this is no worse
than before. For a count of 0 to really behave like a count of 1, would
it need a clamp such as max(channel_cnt, 1), or a per-package bound?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119100625.72505-1-me%407xz.dev
Technical Details
Message-ID:
<179542972017.3135.10691735313982658423@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369242-linux-kernel-netdev=dewy.ruReferences:
<20261119100625.72505-1-me@7xz.dev>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369242-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] net/ncsi: fix channel loop termination when Channel Count is 0 Date: Mon, 23 Nov 2026 10:28:40 +0000 Organization: Usenet Network Message-ID: <179542972017.3135.10691735313982658423@kernel.org> References: <20261119100625.72505-1-me@7xz.dev> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3851551"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:TJy34/Sny5/HUEWXVmsNlp5Yim4= sha256:PULcIQfxHF2wQjM2kopZnXOnQPn4PTs+V167tYOZhH0= sha1:ifSNZUC/t8TUDFc5eAwwbuyKLsA= sha256:Ny8b584vARrlnCiRcKb2GRFEP1yGgUk7g6gdNwYzuZ0= 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 607DE125D96; Mon, 23 Nov 2026 13:29:19 +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 7Zum4SYRD3Pm; Mon, 23 Nov 2026 13:29: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-369242-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 50C72125D99; Mon, 23 Nov 2026 13:29:07 +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 D3B6F365FB; Mon, 23 Nov 2026 10:28:49 +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=1795429728; b=mQHjMUMZdLCAnQqntJogzad3avzj0bx0+0jjaHgk3jsqhysUQXmqknQT7o60EuIghAA8 hTll4sBdO2k7IqIzy5+/MbPTn1iZFCA+Q3vFJKabKavPdlGEZ21Gco2FeKlAog2WYA989 1CE3tVwUSjIJ+0V6gGMpjoQ5YvL1bbQ9OcMPxfnjlorwo7v5qhTL0h+rJSZY43tQ5gVYF 1kf+9KX7Pi4QLMx/DUW5X55YpEKBlF6xAcb/rZiMI/1tqDS/V4SBbwRs9YkqMkvrl0G3d chJvxuhqN+xRmDzkQEVx2J9LwX3RKGLNsq8m4wrg7q4MR4+jvztFxPtLGWMcMOYp/Qg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795429728; 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=3dEABjnP8zG4GS+2RR7xYcv4bokf7sqd6fxlHiM9nZA=; b=yM1F494DWxiQjYH/M0NpWCNS3EC6xXb1+qX8ziDGyj2cGbuoZYuC6KRxzYJLZjcqDV+0 EVxKCw+hDu0NTE3OoCpVpqQf8QKpIWou2z4qiipJCXusW9ZlidHCcr7Rs/0dxizYwsjVi YfhG68akvq0aydEF3Fu9UqgxtGG2vJya1tN1sIPAbTNKQbqau1jSQI9Sg/lWGSnvK/02p dVnXNteWBOh3G4qvmuqviKXCsl5gEUM7Yfqi17B9idHuk5kYsJny8jGJCj9ZwIorGOAkg rbm3gCJgQXRvykwfzDDKh+fs+FazH2ePBlXae8COcHFyVeKKHcz75znWC3FoOyxGhFQ== 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=IAdE3ts2; 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 0E51C606A33B; Mon, 23 Nov 2026 10:28:48 +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=IAdE3ts2 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=1795429722; b=NW7FRPyLyElfgr30xRmukndVdEBUAhsmacwXulnxXbzNRahClNINAlSG967boPszCo0U ZYTfIKzhD4qs9ZE8VLjMqviDtKQ8nTWxg0MNumOsnU5XUqj29uU1kM4GWOFdJf9Gu/0KK qtyCEcQwRyvSXChv8Ri5cEufSbcxtOwwr4WwnIRn2JcXyoN1fklvJcVLXcUKPhznoXaHi 85Zht0rZ6b+ttZLhmX9W1X+hFqr0lE1QZZc41hZE4qDCtcxe52mPBs45AzXNgo+OU1UOf P5XL8LLTqjTCAqzJ1/t6TqUhc7/gTAE7D09vAka2nqg1Ah6Nj+9WqAt/DL8+3g5zmoQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795429722; 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=3dEABjnP8zG4GS+2RR7xYcv4bokf7sqd6fxlHiM9nZA=; b=dHAC+O2tW3jsR2p/C+0e8sqLvtKuX5AKYCn9kConN/jnkhb6yQk3tIfL9LmLCcy8kXjJ 2UxQ6+Umbi53zgTVwA6I9JEzm+ldxk74VBSd6MIWxq+oCfsHLWOVKyGPd4F8+JAPNJBXu RdGXoGOy8c+zDSSVp+ihSpb6cwfaf9Ka0SYsd0S4aElT9Er/aCY4I8ll5G7GdtQPA9rzJ BhW9CZhDKnt1k5JUZPzKywIhDJtAslj2jPxtWUBStCBhC6aFltR9fpYKRusJ0lwmwEkEI On7zO7QMGhU6Lp4zYAkC9nxKK0cVJrOzg9jk0F0D1QXRob7ea9x1O6GFVV8FsmsPmJg== 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=IAdE3ts2; 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 2AEBD606A31A; Mon, 23 Nov 2026 10:28:41 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C7B11F000C6; Mon, 23 Nov 2026 10:28:40 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795429721; bh=3dEABjnP8zG4GS+2RR7xYcv4bokf7sqd6fxlHiM9nZA=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=IAdE3ts28rbpjzsOoVlPyB/OB278tHv2AQSdyKejaw6hKNIDIOQGgQ32ezIjYBLXf 0bgwh/y2fZjTMnYVwTXz0AZwl289IDZnA3ItMV8J1ZCkjTee3PNocDmZN02Maa5u1f +0THhfroqKhVYwyB65eA8zjDEkTMSYqCXI1CKcwZfKYqS3kH3QsLVmJyh+6oiAlTCj J+G13AGJHY8incJaZNbtQTHWrL0ZZuOdz5v2hXjMUq1RAlGzQHqqcqPRGzYxTSyu8o XdJ3GG/gcl++6K2gsX+ZDTTL2pOsHqyveE5p78JkLmTErYtKBMsc0vyR/PM/XbIO2s 8KeWdY180ACZw== X-Cc: sam@mendozajonas.com, fercerpav@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, delphine_cc_chiu@wiwynn.com X-In-Reply-To: <20261119100625.72505-1-me@7xz.dev> X-sashiko-severity: Medium 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