tipc: orphan sock in tipc_release()
authorCong Wang <[email protected]>
Tue, 4 Sep 2018 02:12:41 +0000 (19:12 -0700)
committerDavid S. Miller <[email protected]>
Thu, 6 Sep 2018 05:14:00 +0000 (22:14 -0700)
Before we unlock the sock in tipc_release(), we have to
detach sk->sk_socket from sk, otherwise a parallel
tipc_sk_fill_sock_diag() could stil read it after we
free this socket.

Fixes: c30b70deb5f4 ("tipc: implement socket diagnostics for AF_TIPC")
Reported-and-tested-by: [email protected]
Cc: Jon Maloy <[email protected]>
Cc: Ying Xue <[email protected]>
Signed-off-by: Cong Wang <[email protected]>
Acked-by: Ying Xue <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
net/tipc/socket.c

index ab7a2a7178f7167b2cac5c0f382a8bbda42bf4d5..a0ff8bffc96b17b2e924ff50e51add21c1ff4c87 100644 (file)
@@ -576,6 +576,7 @@ static int tipc_release(struct socket *sock)
        sk_stop_timer(sk, &sk->sk_timer);
        tipc_sk_remove(tsk);
 
+       sock_orphan(sk);
        /* Reject any messages that accumulated in backlog queue */
        release_sock(sk);
        tipc_dest_list_purge(&tsk->cong_links);