]> git.baikalelectronics.ru Git - kernel.git/commit
ipv6: fix a potential deadlock in do_ipv6_setsockopt()
authorWANG Cong <xiyou.wangcong@gmail.com>
Thu, 20 Oct 2016 06:35:12 +0000 (23:35 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 21 Oct 2016 15:29:02 +0000 (11:29 -0400)
commitfa4e9a02365572d3e66663d0dd3492c9d826e432
tree15f086903cd41889f29e23ac2f80d8bb77f7ead4
parent8e02cfe86f5d0db73665c6e4ad7bdb10be8e6e48
ipv6: fix a potential deadlock in do_ipv6_setsockopt()

Baozeng reported this deadlock case:

       CPU0                    CPU1
       ----                    ----
  lock([  165.136033] sk_lock-AF_INET6);
                               lock([  165.136033] rtnl_mutex);
                               lock([  165.136033] sk_lock-AF_INET6);
  lock([  165.136033] rtnl_mutex);

Similar to commit cba1b18e2c59
("ipv4: fix a potential deadlock in mcast getsockopt() path")
this is due to we still have a case, ipv6_sock_mc_close(),
where we acquire sk_lock before rtnl_lock. Close this deadlock
with the similar solution, that is always acquire rtnl lock first.

Fixes: 2ed51ebd23be ("ipv4,ipv6: grab rtnl before locking the socket")
Reported-by: Baozeng Ding <sploving1@gmail.com>
Tested-by: Baozeng Ding <sploving1@gmail.com>
Cc: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Reviewed-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/addrconf.h
net/ipv6/ipv6_sockglue.c
net/ipv6/mcast.c