]> git.baikalelectronics.ru Git - kernel.git/commitdiff
tipc: orphan sock in tipc_release()
authorCong Wang <xiyou.wangcong@gmail.com>
Tue, 4 Sep 2018 02:12:41 +0000 (19:12 -0700)
committerDavid S. Miller <davem@davemloft.net>
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: e9a4ef2a0a6e ("tipc: implement socket diagnostics for AF_TIPC")
Reported-and-tested-by: syzbot+48804b87c16588ad491d@syzkaller.appspotmail.com
Cc: Jon Maloy <jon.maloy@ericsson.com>
Cc: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
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);