netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch net-next v3 0/7] devlink: fix a deadlock when taking devlink instance lock while holding RTNL lock
@ 2023-10-13 12:10 Jiri Pirko
  2023-10-13 12:10 ` [patch net-next v3 1/7] net: treat possible_net_t net pointer as an RCU one and add read_pnet_rcu() Jiri Pirko
                   ` (7 more replies)
  0 siblings, 8 replies; 16+ messages in thread
From: Jiri Pirko @ 2023-10-13 12:10 UTC (permalink / raw)
  To: netdev; +Cc: kuba, pabeni, davem, edumazet

From: Jiri Pirko <jiri@nvidia.com>

devlink_port_fill() may be called sometimes with RTNL lock held.
When putting the nested port function devlink instance attrs,
current code takes nested devlink instance lock. In that case lock
ordering is wrong.

Patch #1 is a dependency of patch #2.
Patch #2 converts the peernet2id_alloc() call to rely in RCU so it could
         called without devlink instance lock.
Patch #3 takes device reference for devlink instance making sure that
         device does not disappear before devlink_release() is called.
Patch #4 benefits from the preparations done in patches #2 and #3 and
         removes the problematic nested devlink lock aquisition.
Patched #5-#7 improve documentation to reflect this issue so it is
              avoided in the future.

Jiri Pirko (7):
  net: treat possible_net_t net pointer as an RCU one and add
    read_pnet_rcu()
  devlink: call peernet2id_alloc() with net pointer under RCU read lock
  devlink: take device reference for devlink object
  devlink: don't take instance lock for nested handle put
  Documentation: devlink: add nested instance section
  Documentation: devlink: add a note about RTNL lock into locking
    section
  devlink: document devlink_rel_nested_in_notify() function

 Documentation/networking/devlink/index.rst | 28 ++++++++++++++++++
 include/net/net_namespace.h                | 15 ++++++++--
 net/devlink/core.c                         | 34 ++++++++++++----------
 net/devlink/netlink.c                      | 12 ++++++--
 4 files changed, 68 insertions(+), 21 deletions(-)

-- 
2.41.0


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

end of thread, other threads:[~2023-10-18  8:30 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-13 12:10 [patch net-next v3 0/7] devlink: fix a deadlock when taking devlink instance lock while holding RTNL lock Jiri Pirko
2023-10-13 12:10 ` [patch net-next v3 1/7] net: treat possible_net_t net pointer as an RCU one and add read_pnet_rcu() Jiri Pirko
2023-10-17  8:49   ` Simon Horman
2023-10-13 12:10 ` [patch net-next v3 2/7] devlink: call peernet2id_alloc() with net pointer under RCU read lock Jiri Pirko
2023-10-17  8:50   ` Simon Horman
2023-10-13 12:10 ` [patch net-next v3 3/7] devlink: take device reference for devlink object Jiri Pirko
2023-10-17  8:50   ` Simon Horman
2023-10-13 12:10 ` [patch net-next v3 4/7] devlink: don't take instance lock for nested handle put Jiri Pirko
2023-10-17  8:51   ` Simon Horman
2023-10-13 12:10 ` [patch net-next v3 5/7] Documentation: devlink: add nested instance section Jiri Pirko
2023-10-17  8:52   ` Simon Horman
2023-10-13 12:10 ` [patch net-next v3 6/7] Documentation: devlink: add a note about RTNL lock into locking section Jiri Pirko
2023-10-17  8:53   ` Simon Horman
2023-10-13 12:10 ` [patch net-next v3 7/7] devlink: document devlink_rel_nested_in_notify() function Jiri Pirko
2023-10-17  8:53   ` Simon Horman
2023-10-18  8:30 ` [patch net-next v3 0/7] devlink: fix a deadlock when taking devlink instance lock while holding RTNL lock patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).