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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 11 Jun 2018 20:49:19 +0000 (22:49 +0200)
commitc6fae49a447ca86d65922f92281d232c3adbb1db
tree9945c76ba44e276e12c796a38d9d62e47dad4fae
parentebe79f9cf44f8d9d3a2ad5b0334b2c6642775b54
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: syzbot+5f1a04e374a635efc426@syzkaller.appspotmail.com
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/kcm/kcmsock.c