]>
Commit | Line | Data |
---|---|---|
e6d488dc GKH |
1 | From foo@baz Tue Jun 12 11:38:32 CEST 2018 |
2 | From: Kirill Tkhai <ktkhai@virtuozzo.com> | |
3 | Date: Fri, 1 Jun 2018 14:30:38 +0300 | |
4 | Subject: kcm: Fix use-after-free caused by clonned sockets | |
5 | ||
6 | From: Kirill Tkhai <ktkhai@virtuozzo.com> | |
7 | ||
8 | [ Upstream commit eb7f54b90bd8f469834c5e86dcf72ebf9a629811 ] | |
9 | ||
10 | (resend for properly queueing in patchwork) | |
11 | ||
12 | kcm_clone() creates kernel socket, which does not take net counter. | |
13 | Thus, the net may die before the socket is completely destructed, | |
14 | i.e. kcm_exit_net() is executed before kcm_done(). | |
15 | ||
16 | Reported-by: syzbot+5f1a04e374a635efc426@syzkaller.appspotmail.com | |
17 | Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com> | |
18 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
19 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
20 | --- | |
21 | net/kcm/kcmsock.c | 2 +- | |
22 | 1 file changed, 1 insertion(+), 1 deletion(-) | |
23 | ||
24 | --- a/net/kcm/kcmsock.c | |
25 | +++ b/net/kcm/kcmsock.c | |
26 | @@ -1671,7 +1671,7 @@ static struct file *kcm_clone(struct soc | |
27 | __module_get(newsock->ops->owner); | |
28 | ||
29 | newsk = sk_alloc(sock_net(osock->sk), PF_KCM, GFP_KERNEL, | |
30 | - &kcm_proto, true); | |
31 | + &kcm_proto, false); | |
32 | if (!newsk) { | |
33 | sock_release(newsock); | |
34 | return ERR_PTR(-ENOMEM); |