Netdev List
 help / color / mirror / Atom feed
* [PATCH v2 net 0/2] net/ncsi: fix RCU list entry lifetime on package and channel removal
@ 2026-11-20 23:54 Tristan Madani
  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
  0 siblings, 2 replies; 3+ messages in thread
From: Tristan Madani @ 2026-11-20 23:54 UTC (permalink / raw)
  To: Samuel Mendoza-Jonas, Paul Fertser
  Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, netdev, linux-kernel, stable, Tristan Madani

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-20 23:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 23:54 [PATCH v2 net 0/2] net/ncsi: fix RCU list entry lifetime on package and channel removal Tristan Madani
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox