Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0ae3ff2e authored by Kirill Tkhai's avatar Kirill Tkhai Committed by Greg Kroah-Hartman
Browse files

kcm: Fix use-after-free caused by clonned sockets



[ Upstream commit eb7f54b90bd8f469834c5e86dcf72ebf9a629811 ]

(resend for properly queueing in patchwork)

kcm_clone() creates kernel socket, which does not take net counter.
Thus, the net may die before the socket is completely destructed,
i.e. kcm_exit_net() is executed before kcm_done().

Reported-by: default avatar <syzbot+5f1a04e374a635efc426@syzkaller.appspotmail.com>
Signed-off-by: default avatarKirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f698b28a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1671,7 +1671,7 @@ static struct file *kcm_clone(struct socket *osock)
	__module_get(newsock->ops->owner);

	newsk = sk_alloc(sock_net(osock->sk), PF_KCM, GFP_KERNEL,
			 &kcm_proto, true);
			 &kcm_proto, false);
	if (!newsk) {
		sock_release(newsock);
		return ERR_PTR(-ENOMEM);