Commit 56440d7
genetlink: hold RCU in genlmsg_mcast()
While running net selftests with CONFIG_PROVE_RCU_LIST=y I saw
one lockdep splat [1].
genlmsg_mcast() uses for_each_net_rcu(), and must therefore hold RCU.
Instead of letting all callers guard genlmsg_multicast_allns()
with a rcu_read_lock()/rcu_read_unlock() pair, do it in genlmsg_mcast().
This also means the @flags parameter is useless, we need to always use
GFP_ATOMIC.
[1]
[10882.424136] =============================
[10882.424166] WARNING: suspicious RCU usage
[10882.424309] 6.12.0-rc2-virtme torvalds#1156 Not tainted
[10882.424400] -----------------------------
[10882.424423] net/netlink/genetlink.c:1940 RCU-list traversed in non-reader section!!
[10882.424469]
other info that might help us debug this:
[10882.424500]
rcu_scheduler_active = 2, debug_locks = 1
[10882.424744] 2 locks held by ip/15677:
[10882.424791] #0: ffffffffb6b491b0 (cb_lock){++++}-{3:3}, at: genl_rcv (net/netlink/genetlink.c:1219)
[10882.426334] #1: ffffffffb6b49248 (genl_mutex){+.+.}-{3:3}, at: genl_rcv_msg (net/netlink/genetlink.c:61 net/netlink/genetlink.c:57 net/netlink/genetlink.c:1209)
[10882.426465]
stack backtrace:
[10882.426805] CPU: 14 UID: 0 PID: 15677 Comm: ip Not tainted 6.12.0-rc2-virtme torvalds#1156
[10882.426919] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[10882.427046] Call Trace:
[10882.427131] <TASK>
[10882.427244] dump_stack_lvl (lib/dump_stack.c:123)
[10882.427335] lockdep_rcu_suspicious (kernel/locking/lockdep.c:6822)
[10882.427387] genlmsg_multicast_allns (net/netlink/genetlink.c:1940 (discriminator 7) net/netlink/genetlink.c:1977 (discriminator 7))
[10882.427436] l2tp_tunnel_notify.constprop.0 (net/l2tp/l2tp_netlink.c:119) l2tp_netlink
[10882.427683] l2tp_nl_cmd_tunnel_create (net/l2tp/l2tp_netlink.c:253) l2tp_netlink
[10882.427748] genl_family_rcv_msg_doit (net/netlink/genetlink.c:1115)
[10882.427834] genl_rcv_msg (net/netlink/genetlink.c:1195 net/netlink/genetlink.c:1210)
[10882.427877] ? __pfx_l2tp_nl_cmd_tunnel_create (net/l2tp/l2tp_netlink.c:186) l2tp_netlink
[10882.427927] ? __pfx_genl_rcv_msg (net/netlink/genetlink.c:1201)
[10882.427959] netlink_rcv_skb (net/netlink/af_netlink.c:2551)
[10882.428069] genl_rcv (net/netlink/genetlink.c:1220)
[10882.428095] netlink_unicast (net/netlink/af_netlink.c:1332 net/netlink/af_netlink.c:1357)
[10882.428140] netlink_sendmsg (net/netlink/af_netlink.c:1901)
[10882.428210] ____sys_sendmsg (net/socket.c:729 (discriminator 1) net/socket.c:744 (discriminator 1) net/socket.c:2607 (discriminator 1))
Fixes: 33f72e6 ("l2tp : multicast notification to the registered listeners")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: James Chapman <jchapman@katalix.com>
Cc: Tom Parkin <tparkin@katalix.com>
Cc: Johannes Berg <johannes.berg@intel.com>
Link: https://patch.msgid.link/20241011171217.3166614-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>1 parent 1833d8a commit 56440d7
File tree
5 files changed
+20
-25
lines changed- drivers/target
- include/net
- net
- l2tp
- netlink
- wireless
5 files changed
+20
-25
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2130 | 2130 | | |
2131 | 2131 | | |
2132 | 2132 | | |
2133 | | - | |
| 2133 | + | |
2134 | 2134 | | |
2135 | 2135 | | |
2136 | 2136 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
534 | | - | |
535 | 534 | | |
536 | 535 | | |
537 | 536 | | |
538 | 537 | | |
539 | 538 | | |
540 | | - | |
| 539 | + | |
541 | 540 | | |
542 | 541 | | |
543 | 542 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
| 119 | + | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
| 147 | + | |
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1501 | 1501 | | |
1502 | 1502 | | |
1503 | 1503 | | |
1504 | | - | |
| 1504 | + | |
1505 | 1505 | | |
1506 | 1506 | | |
1507 | | - | |
1508 | | - | |
1509 | | - | |
1510 | | - | |
1511 | | - | |
1512 | | - | |
| 1507 | + | |
| 1508 | + | |
1513 | 1509 | | |
1514 | 1510 | | |
1515 | 1511 | | |
| |||
1929 | 1925 | | |
1930 | 1926 | | |
1931 | 1927 | | |
1932 | | - | |
1933 | | - | |
| 1928 | + | |
1934 | 1929 | | |
1935 | 1930 | | |
1936 | 1931 | | |
1937 | 1932 | | |
1938 | 1933 | | |
1939 | 1934 | | |
| 1935 | + | |
1940 | 1936 | | |
1941 | 1937 | | |
1942 | | - | |
| 1938 | + | |
1943 | 1939 | | |
1944 | 1940 | | |
1945 | 1941 | | |
1946 | 1942 | | |
1947 | 1943 | | |
1948 | | - | |
| 1944 | + | |
1949 | 1945 | | |
1950 | 1946 | | |
1951 | 1947 | | |
| |||
1954 | 1950 | | |
1955 | 1951 | | |
1956 | 1952 | | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
1957 | 1956 | | |
1958 | | - | |
1959 | 1957 | | |
1960 | 1958 | | |
1961 | 1959 | | |
1962 | 1960 | | |
1963 | 1961 | | |
1964 | 1962 | | |
| 1963 | + | |
| 1964 | + | |
1965 | 1965 | | |
1966 | 1966 | | |
1967 | 1967 | | |
1968 | 1968 | | |
1969 | 1969 | | |
1970 | 1970 | | |
1971 | | - | |
| 1971 | + | |
1972 | 1972 | | |
1973 | 1973 | | |
1974 | 1974 | | |
1975 | 1975 | | |
1976 | 1976 | | |
1977 | | - | |
| 1977 | + | |
1978 | 1978 | | |
1979 | 1979 | | |
1980 | 1980 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17986 | 17986 | | |
17987 | 17987 | | |
17988 | 17988 | | |
17989 | | - | |
17990 | 17989 | | |
17991 | | - | |
17992 | | - | |
| 17990 | + | |
17993 | 17991 | | |
17994 | 17992 | | |
17995 | 17993 | | |
| |||
18722 | 18720 | | |
18723 | 18721 | | |
18724 | 18722 | | |
18725 | | - | |
18726 | 18723 | | |
18727 | | - | |
18728 | | - | |
| 18724 | + | |
18729 | 18725 | | |
18730 | 18726 | | |
18731 | 18727 | | |
| |||
0 commit comments