aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/rtnetlink.h
diff options
context:
space:
mode:
authorKuniyuki Iwashima <kuniyu@amazon.com>2024-11-07 16:48:15 -0800
committerJakub Kicinski <kuba@kernel.org>2024-11-11 17:26:51 -0800
commit6b57ff21a3109b1dba2d286ff415463e6fb1fca3 (patch)
tree422ce0bd4dd0ae915e044478a5fd83a1a5a2a977 /include/net/rtnetlink.h
parentrtnetlink: Remove __rtnl_link_unregister(). (diff)
downloadlinux-6b57ff21a3109b1dba2d286ff415463e6fb1fca3.tar.gz
linux-6b57ff21a3109b1dba2d286ff415463e6fb1fca3.zip
rtnetlink: Protect link_ops by mutex.
rtnl_link_unregister() holds RTNL and calls synchronize_srcu(), but rtnl_newlink() will acquire SRCU frist and then RTNL. Then, we need to unlink ops and call synchronize_srcu() outside of RTNL to avoid the deadlock. rtnl_link_unregister() rtnl_newlink() ---- ---- lock(rtnl_mutex); lock(&ops->srcu); lock(rtnl_mutex); sync(&ops->srcu); Let's move as such and add a mutex to protect link_ops. Now, link_ops is protected by its dedicated mutex and rtnl_link_register() no longer needs to hold RTNL. While at it, we move the initialisation of ops->dellink and ops->srcu out of the mutex scope. Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com> Link: https://patch.msgid.link/20241108004823.29419-3-kuniyu@amazon.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include/net/rtnetlink.h')
-rw-r--r--include/net/rtnetlink.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
index 3ebfcc6e56fd..7559020f760c 100644
--- a/include/net/rtnetlink.h
+++ b/include/net/rtnetlink.h
@@ -71,7 +71,7 @@ static inline int rtnl_msg_family(const struct nlmsghdr *nlh)
/**
* struct rtnl_link_ops - rtnetlink link operations
*
- * @list: Used internally, protected by RTNL and SRCU
+ * @list: Used internally, protected by link_ops_mutex and SRCU
* @srcu: Used internally
* @kind: Identifier
* @netns_refund: Physical device, move to init_net on netns exit