]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
kcm: Fix use-after-free caused by clonned sockets
authorKirill Tkhai <ktkhai@virtuozzo.com>
Fri, 1 Jun 2018 11:30:38 +0000 (14:30 +0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 1 Jun 2018 14:28:07 +0000 (10:28 -0400)
(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: syzbot+5f1a04e374a635efc426@syzkaller.appspotmail.com
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/kcm/kcmsock.c

index dc76bc34682901e4dac8c00503e9c5da7d997dec..d3601d421571b9825ff0a6cea9b75cb52fd51dea 100644 (file)
@@ -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);