]> git.baikalelectronics.ru Git - kernel.git/commit
net, sk_msg: Don't check if sock is locked when tearing down psock
authorJakub Sitnicki <jakub@cloudflare.com>
Tue, 21 Jan 2020 12:31:47 +0000 (13:31 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 22 Jan 2020 19:30:20 +0000 (20:30 +0100)
commitcd3b979330d9c7c76a62da297e08743b3cd9e0ee
tree555b6341eafcee8b16cb7d6a8f59701582085f50
parent29cda8c4a719f0a55b61441d7e1fcae5cccc9987
net, sk_msg: Don't check if sock is locked when tearing down psock

As John Fastabend reports [0], psock state tear-down can happen on receive
path *after* unlocking the socket, if the only other psock user, that is
sockmap or sockhash, releases its psock reference before tcp_bpf_recvmsg
does so:

 tcp_bpf_recvmsg()
  psock = sk_psock_get(sk)                         <- refcnt 2
  lock_sock(sk);
  ...
                                  sock_map_free()  <- refcnt 1
  release_sock(sk)
  sk_psock_put()                                   <- refcnt 0

Remove the lockdep check for socket lock in psock tear-down that got
introduced in 5fc6321e4997 ("bpf: Sockmap, ensure sock lock held during
tear down").

[0] https://lore.kernel.org/netdev/5e25dc995d7d_74082aaee6e465b441@john-XPS-13-9370.notmuch/

Fixes: 5fc6321e4997 ("bpf: Sockmap, ensure sock lock held during tear down")
Reported-by: syzbot+d73682fcf7fee6982fe3@syzkaller.appspotmail.com
Suggested-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/skmsg.c