All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH can-next v2 0/3] can: take rtnl_lock() before leaving the notifier list
@ 2026-10-14 14:21 Oliver Hartkopp
  2026-10-14 14:21 ` [PATCH can-next v2 1/3] can: isotp: fix filter removal race between release and netns change Oliver Hartkopp
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Oliver Hartkopp @ 2026-10-14 14:21 UTC (permalink / raw)
  To: linux-can; +Cc: Oliver Hartkopp

Norbert Szetei reported a use-after-free in isotp: isotp_release()
removes the socket from the netdev notifier list before it takes
rtnl_lock(). A socket that leaves the list in this window is skipped by
the notifier and has to remove its CAN filters itself. If the bound
device is moved to another network namespace in this window,
can_rx_unregister() silently skips the removal due to the namespace
mismatch and the remaining receivers point to the freed socket.

bcm has the same window and is affected in the same way. raw has the
window too, but removes its filters with dev_net(ro->dev) under RTNL
and is therefore not affected.

This series takes rtnl_lock() before the socket leaves the notifier
list in all three protocols. As the notifier chain is always invoked
under RTNL, the busy-wait loops on the *_busy_notifier variables are
dead code and are replaced with WARN_ON_ONCE().

Link: https://lore.kernel.org/linux-can/CEA6A38A-2646-4ADA-95B4-CBAE2F301A8E@doyensec.com/

Changes in v2:
- bcm: remove the procfs entry and the tx_ops before taking RTNL so
  that remove_proc_entry() can not stall RTNL waiting for readers of
  the world-readable procfs entry
- bcm, raw: reword the commit messages so that they do not refer to
  patches outside of this series
- send all three patches as one series for can-next

Oliver Hartkopp (3):
  can: isotp: fix filter removal race between release and netns change
  can: bcm: fix filter removal race between release and netns change
  can: raw: take rtnl_lock() before leaving the notifier list

 net/can/bcm.c   | 35 +++++++++++++++++++++++++----------
 net/can/isotp.c | 17 +++++++++--------
 net/can/raw.c   | 13 +++++++------
 3 files changed, 41 insertions(+), 24 deletions(-)

-- 
2.53.0


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

end of thread, other threads:[~2026-10-14 21:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-14 14:21 [PATCH can-next v2 0/3] can: take rtnl_lock() before leaving the notifier list Oliver Hartkopp
2026-10-14 14:21 ` [PATCH can-next v2 1/3] can: isotp: fix filter removal race between release and netns change Oliver Hartkopp
2026-10-14 14:21 ` [PATCH can-next v2 2/3] can: bcm: " Oliver Hartkopp
2026-10-14 14:21 ` [PATCH can-next v2 3/3] can: raw: take rtnl_lock() before leaving the notifier list Oliver Hartkopp
2026-10-14 21:42 ` [PATCH can-next v2 0/3] can: " Marc Kleine-Budde

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.