tipc: orphan sock in tipc_release()

This change “tipc: orphan sock in tipc_release()” (commit 0a3b8b2) in Linux kernel is authored by Cong Wang <xiyou.wangcong [at] gmail.com> on Mon Sep 3 19:12:41 2018 -0700.

Description of "tipc: orphan sock in tipc_release()"

The change “tipc: orphan sock in tipc_release()” introduces changes as follows.

tipc: orphan sock in tipc_release()

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: 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>

Linux kernel releases containing commit 0a3b8b2

The Linux kernel releases containing this commit are as follows.

Linux kernel code changes from "tipc: orphan sock in tipc_release()"

There is one line of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 net/tipc/socket.c | 1 +
 1 file changed, 1 insertion(+)
 
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index ab7a2a7178f7..a0ff8bffc96b 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -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);

The commit for this change in Linux stable tree is 0a3b8b2 (patch).

Last modified: 2020/02/09