From: Ian Rogers <irogers@google.com>
To: Samuel Mendoza-Jonas <sam@mendozajonas.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Paul Fertser <fercerpav@gmail.com>,
Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, Elkin Cruz <elkin@google.com>,
Ian Rogers <irogers@google.com>
Subject: [PATCH net] ncsi: Initialize vid in set_one_vid() to handle concurrent VLAN removal
Date: Thu, 19 Nov 2026 09:10:09 -0800 [thread overview]
Message-ID: <20261119171009.1534335-1-irogers@google.com> (raw)
set_one_vid() checks list_empty(&ndp->vlan_vids) before acquiring
nc->lock and rcu_read_lock(). If ncsi_vlan_rx_kill_vid() removes the
last VLAN entry in that window, list_for_each_entry_rcu() executes
zero iterations and leaves vid uninitialized on the stack. The
subsequent 'if (!vid)' check can then proceed and program stack
garbage into ncf->vids[index] and an NCSI_PKT_CMD_SVF command packet.
Initialize vid to 0 so that an empty RCU list cleanly hits 'if (!vid)'
and returns -1.
Found via Clang -Wconditional-uninitialized on an x86_64 allyesconfig
build. Verified by building net/ncsi/ncsi-manage.o with LLVM=1 W=1
(-Werror) and -Wconditional-uninitialized; not runtime-tested on NCSI
hardware.
Fixes: 062b3e1b6d4f ("net/ncsi: Refactor MAC, VLAN filters")
Signed-off-by: Ian Rogers <irogers@google.com>
---
net/ncsi/ncsi-manage.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c
index 1d63958c4429..f7eca228c281 100644
--- a/net/ncsi/ncsi-manage.c
+++ b/net/ncsi/ncsi-manage.c
@@ -640,7 +640,7 @@ static int set_one_vid(struct ncsi_dev_priv *ndp, struct ncsi_channel *nc,
unsigned long flags;
int i, index;
void *bitmap;
- u16 vid;
+ u16 vid = 0;
if (list_empty(&ndp->vlan_vids))
return -1;
--
2.56.1.708.g77570a6a1d-goog
reply other threads:[~2026-11-19 17:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261119171009.1534335-1-irogers@google.com \
--to=irogers@google.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=elkin@google.com \
--cc=fercerpav@gmail.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sam@mendozajonas.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