Skip to content

devlink: fix a deadlock when taking devlink instance lock while holding RTNL lock

Jiri Pirko netdev 3 versions – Applied

Status from this message: This series was applied to netdev/net-next.git (main)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest7 patches 7 repliesApplied 7/7
  2. v23 patches 2 repliesSuperseded
  3. v11 patch 20 repliesSuperseded

Patches in v3 All 7 applied

#Subject and filesSizeRepliesApplied
1/7net: treat possible_net_t net pointer as an RCU one and add read_pnet_rcu()include/net/net_namespace.h+12 -31 replyApplied
2/7devlink: call peernet2id_alloc() with net pointer under RCU read locknet/devlink/netlink.c+9 -31 replyApplied
3/7devlink: take device reference for devlink objectnet/devlink/core.c+2 -11 replyApplied
4/7devlink: don't take instance lock for nested handle putnet/devlink/core.c+3 -141 replyApplied
5/7Documentation: devlink: add nested instance sectionDocumentation/networking/devlink/index.rst+24 -01 replyApplied
6/7Documentation: devlink: add a note about RTNL lock into locking sectionDocumentation/networking/devlink/index.rst+4 -01 replyApplied
7/7devlink: document devlink_rel_nested_in_notify() functionnet/devlink/core.c+14 -01 replyApplied

Reviews trailers per patch

All 7 patches have a Reviewed-by or Acked-by.

PatchSimon Horman
1/7R-b
2/7R-b
3/7R-b
4/7R-b
5/7R-b
6/7R-b
7/7R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [patch net-next v3 0/7] devlink: fix a deadlock when taking devlink instance lock while holding RTNL lock

From: Jiri Pirko <[email protected]>

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(-)
Signature · 1 line
2.41.0