tcp: fix a possible lockdep splat in tcp_done()
Subsystems (3)
PATCH 1/1 tcp: fix a possible lockdep splat in tcp_done()
syzbot found that if __inet_inherit_port() returns an error, we call tcp_done() after inet_csk_prepare_forced_close(), meaning the socket lock is no longer held.
We might fix this in a different way in net-next, but for 5.4 it seems safer to relax the lockdep check.
Fixes d983ea6f16b8 ("tcp: add rcu protection around tp->fastopen_rsk")
Signed-off-by Eric Dumazet <[email protected]>
Reported-by syzbot <[email protected]>
--- net/ipv4/tcp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
net/ipv4/tcp.c +6 -2
@@ -3842,8 +3842,12 @@ void tcp_done(struct sock *sk) {struct request_sock *req; - req =rcu_dereference_protected (tcp_sk (sk)->fastopen_rsk, -lockdep_sock_is_held (sk)); +/* We might be called with a new socket, after +* inet_csk_prepare_forced_close() has been called +* so we can not use lockdep_sock_is_held(sk) +*/ + req =rcu_dereference_protected (tcp_sk (sk)->fastopen_rsk,1 ); +if (sk->sk_state ==TCP_SYN_SENT || sk->sk_state ==TCP_SYN_RECV )TCP_INC_STATS (sock_net (sk),TCP_MIB_ATTEMPTFAILS );
Signature · 1 line
2.23.0.700.g56cf767bdb-goog
From: Eric Dumazet <[email protected]>
Date: Mon, 14 Oct 2019 06:47:57 -0700
Quoted 10 lines
syzbot found that if
__inet_inherit_port()returns an error, we calltcp_done()afterinet_csk_prepare_forced_close(), meaning the socket lock is no longer held.We might fix this in a different way in net-next, but for 5.4 it seems safer to relax the lockdep check.
Fixes d983ea6f16b8 ("tcp: add rcu protection around tp->fastopen_rsk")Signed-off-by Eric Dumazet <[email protected]>Reported-by syzbot <[email protected]>
Applied.