diff options
author | WANG Cong <xiyou.wangcong@gmail.com> | 2017-04-12 21:32:13 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-04-17 18:46:50 +0200 |
commit | 1215e51edad1272e669172b26aa12aac94810c7f (patch) | |
tree | 273156966c9fb351ee4181712ebbcfc576495258 /net/ipv4/raw.c | |
parent | sfc: limit the number of receive queues (diff) | |
download | linux-1215e51edad1272e669172b26aa12aac94810c7f.tar.xz linux-1215e51edad1272e669172b26aa12aac94810c7f.zip |
ipv4: fix a deadlock in ip_ra_control
Similar to commit 87e9f0315952
("ipv4: fix a potential deadlock in mcast getsockopt() path"),
there is a deadlock scenario for IP_ROUTER_ALERT too:
CPU0 CPU1
---- ----
lock(rtnl_mutex);
lock(sk_lock-AF_INET);
lock(rtnl_mutex);
lock(sk_lock-AF_INET);
Fix this by always locking RTNL first on all setsockopt() paths.
Note, after this patch ip_ra_lock is no longer needed either.
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/raw.c')
-rw-r--r-- | net/ipv4/raw.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index 8119e1f66e03..9d943974de2b 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c @@ -682,7 +682,9 @@ static void raw_close(struct sock *sk, long timeout) /* * Raw sockets may have direct kernel references. Kill them. */ + rtnl_lock(); ip_ra_control(sk, 0, NULL); + rtnl_unlock(); sk_common_release(sk); } |