From: Tristan Madani <tristmd@gmail.com>
To: Samuel Mendoza-Jonas <sam@mendozajonas.com>,
Paul Fertser <fercerpav@gmail.com>
Cc: "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org,
Tristan Madani <tristan@talencesecurity.com>
Subject: [PATCH v2 net 0/2] net/ncsi: fix RCU list entry lifetime on package and channel removal
Date: Fri, 20 Nov 2026 23:54:05 +0000 [thread overview]
Message-ID: <20261120235407.1911365-1-tristmd@gmail.com> (raw)
From: Tristan Madani <tristan@talencesecurity.com>
The NCSI package/channel/device removal paths call list_del_rcu()
followed by immediate kfree(). This races with concurrent readers
(primarily the unprivileged NCSI_CMD_PKG_INFO netlink handler) that
walk the same lists with list_for_each_entry_rcu() but never enter
an RCU read-side critical section.
Patch 1 adds the missing rcu_read_lock()/rcu_read_unlock() to the
reader paths so kfree_rcu() on the write side has matching readers
to wait for.
Patch 2 defers the free side: channels use call_rcu() with a
callback that also frees filter sub-allocations, packages and the
device structure use kfree_rcu_mightsleep(), and the work is
quiesced before packages are removed.
Pre-existing issues noted by sashiko-bot review -- dangling
active_channel/hot_channel/preferred_channel pointers, unquiesced
per-request timers, and the ftgmac100 unregister ordering -- are not
addressed here. They affect the overall NCSI teardown design and
are better handled in a dedicated series.
Tristan Madani (2):
net/ncsi: add missing rcu_read_lock to netlink and device list walks
net/ncsi: defer free of removed list entries to an RCU grace period
net/ncsi/internal.h | 1 +
net/ncsi/ncsi-manage.c | 39 ++++++++++++++++++++++++---------------
net/ncsi/ncsi-netlink.c | 32 +++++++++++++++++++++-----------
3 files changed, 46 insertions(+), 26 deletions(-)
---
Changes in v2:
- Rework as a 2-patch series fixing both reader and writer sides
instead of a single patch that only fixed the writer side
- Add rcu_read_lock() on the reader side: ncsi_find_dev(),
ncsi_write_package_info(), ncsi_pkg_info_all_nl() (sashiko-bot)
- Defer channel sub-allocation frees (mac_filter.addrs,
vlan_filter.vids) to the RCU callback so readers cannot follow
stale pointers during the grace period (sashiko-bot)
- Move disable_work_sync() before package removal in
ncsi_unregister_dev() so the work function is quiesced before
any structures are freed (sashiko-bot)
- Fix Fixes: tag hash from 2d283bdd5b20 to 2d283bdd079c
("net/ncsi: Resource management") (sashiko-bot)
- Include discovery method per sashiko-bot request
--
2.47.3
next reply other threads:[~2026-11-20 23:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 23:54 Tristan Madani [this message]
2026-11-20 23:54 ` [PATCH v2 net 1/2] net/ncsi: add missing rcu_read_lock to netlink and device list walks Tristan Madani
2026-11-20 23:54 ` [PATCH v2 net 2/2] net/ncsi: defer free of removed list entries to an RCU grace period Tristan Madani
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=20261120235407.1911365-1-tristmd@gmail.com \
--to=tristmd@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=fercerpav@gmail.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sam@mendozajonas.com \
--cc=stable@vger.kernel.org \
--cc=tristan@talencesecurity.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
all inboxes | Powered by JetHome®