* [PATCH net] tcp: do not inherit mc_list from parent
@ 2017-05-09 12:17 Eric Dumazet
2017-05-09 13:23 ` Eric Dumazet
2017-05-09 13:29 ` [PATCH v2 net] dccp/tcp: " Eric Dumazet
0 siblings, 2 replies; 7+ messages in thread
From: Eric Dumazet @ 2017-05-09 12:17 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Pray3r, Andrey Konovalov
From: Eric Dumazet <edumazet@google.com>
syzkaller found a way to trigger double frees from ip_mc_drop_socket()
It turns out that leave a copy of parent mc_list at accept() time,
which is very bad.
Very similar to commit 8b485ce69876 ("tcp: do not inherit
fastopen_req from parent")
Initial report from Pray3r, completed by Andrey one.
Thanks a lot to them !
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Pray3r <pray3r.z@gmail.com>
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
---
Notes:
- day-0 bug.
- Not sure if it makes sense for TCP socket to be able to join MC
group ?
net/ipv4/tcp_minisocks.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 717be4de53248352c758b50557987d898340dd4f..03035e2857fc8b6e4cd8af6e46e81048d4de9105 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -448,6 +448,7 @@ struct sock *tcp_create_openreq_child(const struct sock *sk,
minmax_reset(&newtp->rtt_min, tcp_time_stamp, ~0U);
newicsk->icsk_rto = TCP_TIMEOUT_INIT;
newicsk->icsk_ack.lrcvtime = tcp_time_stamp;
+ newicsk->icsk_inet.mc_list = NULL;
newtp->packets_out = 0;
newtp->retrans_out = 0;
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net] tcp: do not inherit mc_list from parent
2017-05-09 12:17 [PATCH net] tcp: do not inherit mc_list from parent Eric Dumazet
@ 2017-05-09 13:23 ` Eric Dumazet
2017-05-09 13:30 ` David Miller
2017-05-09 13:29 ` [PATCH v2 net] dccp/tcp: " Eric Dumazet
1 sibling, 1 reply; 7+ messages in thread
From: Eric Dumazet @ 2017-05-09 13:23 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Pray3r, Andrey Konovalov
On Tue, 2017-05-09 at 05:17 -0700, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
>
> syzkaller found a way to trigger double frees from ip_mc_drop_socket()
>
> It turns out that leave a copy of parent mc_list at accept() time,
> which is very bad.
>
> Very similar to commit 8b485ce69876 ("tcp: do not inherit
> fastopen_req from parent")
>
> Initial report from Pray3r, completed by Andrey one.
> Thanks a lot to them !
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Reported-by: Pray3r <pray3r.z@gmail.com>
> Reported-by: Andrey Konovalov <andreyknvl@google.com>
> Tested-by: Andrey Konovalov <andreyknvl@google.com>
> ---
> Notes:
> - day-0 bug.
> - Not sure if it makes sense for TCP socket to be able to join MC
> group ?
I will send a V2, putting the fix in inet_csk_clone_lock() so that DCCP
is also fixed ;)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 net] dccp/tcp: do not inherit mc_list from parent
2017-05-09 12:17 [PATCH net] tcp: do not inherit mc_list from parent Eric Dumazet
2017-05-09 13:23 ` Eric Dumazet
@ 2017-05-09 13:29 ` Eric Dumazet
2017-05-09 19:18 ` David Miller
2017-05-09 22:37 ` Cong Wang
1 sibling, 2 replies; 7+ messages in thread
From: Eric Dumazet @ 2017-05-09 13:29 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Pray3r, Andrey Konovalov
From: Eric Dumazet <edumazet@google.com>
syzkaller found a way to trigger double frees from ip_mc_drop_socket()
It turns out that leave a copy of parent mc_list at accept() time,
which is very bad.
Very similar to commit 8b485ce69876 ("tcp: do not inherit
fastopen_req from parent")
Initial report from Pray3r, completed by Andrey one.
Thanks a lot to them !
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Pray3r <pray3r.z@gmail.com>
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
---
v2: fix moved into inet_csk_clone_lock() to fix both DCCP and TCP
net/ipv4/inet_connection_sock.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 5e313c1ac94fc88eca5fe3a0e9e46e551e955ff0..1054d330bf9df3189a21dbb08e27c0e6ad136775 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -794,6 +794,8 @@ struct sock *inet_csk_clone_lock(const struct sock *sk,
/* listeners have SOCK_RCU_FREE, not the children */
sock_reset_flag(newsk, SOCK_RCU_FREE);
+ inet_sk(newsk)->mc_list = NULL;
+
newsk->sk_mark = inet_rsk(req)->ir_mark;
atomic64_set(&newsk->sk_cookie,
atomic64_read(&inet_rsk(req)->ir_cookie));
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net] tcp: do not inherit mc_list from parent
2017-05-09 13:23 ` Eric Dumazet
@ 2017-05-09 13:30 ` David Miller
0 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2017-05-09 13:30 UTC (permalink / raw)
To: eric.dumazet; +Cc: netdev, pray3r.z, andreyknvl
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Tue, 09 May 2017 06:23:35 -0700
> I will send a V2, putting the fix in inet_csk_clone_lock() so that DCCP
> is also fixed ;)
Thank you :)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 net] dccp/tcp: do not inherit mc_list from parent
2017-05-09 13:29 ` [PATCH v2 net] dccp/tcp: " Eric Dumazet
@ 2017-05-09 19:18 ` David Miller
2017-05-09 22:37 ` Cong Wang
1 sibling, 0 replies; 7+ messages in thread
From: David Miller @ 2017-05-09 19:18 UTC (permalink / raw)
To: eric.dumazet; +Cc: netdev, pray3r.z, andreyknvl
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Tue, 09 May 2017 06:29:19 -0700
> From: Eric Dumazet <edumazet@google.com>
>
> syzkaller found a way to trigger double frees from ip_mc_drop_socket()
>
> It turns out that leave a copy of parent mc_list at accept() time,
> which is very bad.
>
> Very similar to commit 8b485ce69876 ("tcp: do not inherit
> fastopen_req from parent")
>
> Initial report from Pray3r, completed by Andrey one.
> Thanks a lot to them !
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Reported-by: Pray3r <pray3r.z@gmail.com>
> Reported-by: Andrey Konovalov <andreyknvl@google.com>
> Tested-by: Andrey Konovalov <andreyknvl@google.com>
> ---
> v2: fix moved into inet_csk_clone_lock() to fix both DCCP and TCP
Applied and queued up for -stable, thanks Eric.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 net] dccp/tcp: do not inherit mc_list from parent
2017-05-09 13:29 ` [PATCH v2 net] dccp/tcp: " Eric Dumazet
2017-05-09 19:18 ` David Miller
@ 2017-05-09 22:37 ` Cong Wang
2017-05-09 22:51 ` Eric Dumazet
1 sibling, 1 reply; 7+ messages in thread
From: Cong Wang @ 2017-05-09 22:37 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David Miller, netdev, Pray3r, Andrey Konovalov
On Tue, May 9, 2017 at 6:29 AM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> From: Eric Dumazet <edumazet@google.com>
>
> syzkaller found a way to trigger double frees from ip_mc_drop_socket()
>
> It turns out that leave a copy of parent mc_list at accept() time,
> which is very bad.
>
> Very similar to commit 8b485ce69876 ("tcp: do not inherit
> fastopen_req from parent")
>
> Initial report from Pray3r, completed by Andrey one.
> Thanks a lot to them !
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Reported-by: Pray3r <pray3r.z@gmail.com>
> Reported-by: Andrey Konovalov <andreyknvl@google.com>
> Tested-by: Andrey Konovalov <andreyknvl@google.com>
> ---
> v2: fix moved into inet_csk_clone_lock() to fix both DCCP and TCP
>
> net/ipv4/inet_connection_sock.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
> index 5e313c1ac94fc88eca5fe3a0e9e46e551e955ff0..1054d330bf9df3189a21dbb08e27c0e6ad136775 100644
> --- a/net/ipv4/inet_connection_sock.c
> +++ b/net/ipv4/inet_connection_sock.c
> @@ -794,6 +794,8 @@ struct sock *inet_csk_clone_lock(const struct sock *sk,
> /* listeners have SOCK_RCU_FREE, not the children */
> sock_reset_flag(newsk, SOCK_RCU_FREE);
>
> + inet_sk(newsk)->mc_list = NULL;
> +
> newsk->sk_mark = inet_rsk(req)->ir_mark;
> atomic64_set(&newsk->sk_cookie,
> atomic64_read(&inet_rsk(req)->ir_cookie));
>
I think IPv6 needs this too?
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index aeb9497..b3611d9 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1062,6 +1062,7 @@ static struct sock *tcp_v6_syn_recv_sock(const
struct sock *sk, struct sk_buff *
newtp->af_specific = &tcp_sock_ipv6_mapped_specific;
#endif
+ newnp->ipv6_mc_list = NULL;
newnp->ipv6_ac_list = NULL;
newnp->ipv6_fl_list = NULL;
newnp->pktoptions = NULL;
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 net] dccp/tcp: do not inherit mc_list from parent
2017-05-09 22:37 ` Cong Wang
@ 2017-05-09 22:51 ` Eric Dumazet
0 siblings, 0 replies; 7+ messages in thread
From: Eric Dumazet @ 2017-05-09 22:51 UTC (permalink / raw)
To: Cong Wang; +Cc: David Miller, netdev, Pray3r, Andrey Konovalov
On Tue, 2017-05-09 at 15:37 -0700, Cong Wang wrote:
> On Tue, May 9, 2017 at 6:29 AM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> > From: Eric Dumazet <edumazet@google.com>
> >
> > syzkaller found a way to trigger double frees from ip_mc_drop_socket()
> >
> > It turns out that leave a copy of parent mc_list at accept() time,
> > which is very bad.
> >
> > Very similar to commit 8b485ce69876 ("tcp: do not inherit
> > fastopen_req from parent")
> >
> > Initial report from Pray3r, completed by Andrey one.
> > Thanks a lot to them !
> >
> > Signed-off-by: Eric Dumazet <edumazet@google.com>
> > Reported-by: Pray3r <pray3r.z@gmail.com>
> > Reported-by: Andrey Konovalov <andreyknvl@google.com>
> > Tested-by: Andrey Konovalov <andreyknvl@google.com>
> > ---
> > v2: fix moved into inet_csk_clone_lock() to fix both DCCP and TCP
> >
> > net/ipv4/inet_connection_sock.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
> > index 5e313c1ac94fc88eca5fe3a0e9e46e551e955ff0..1054d330bf9df3189a21dbb08e27c0e6ad136775 100644
> > --- a/net/ipv4/inet_connection_sock.c
> > +++ b/net/ipv4/inet_connection_sock.c
> > @@ -794,6 +794,8 @@ struct sock *inet_csk_clone_lock(const struct sock *sk,
> > /* listeners have SOCK_RCU_FREE, not the children */
> > sock_reset_flag(newsk, SOCK_RCU_FREE);
> >
> > + inet_sk(newsk)->mc_list = NULL;
> > +
> > newsk->sk_mark = inet_rsk(req)->ir_mark;
> > atomic64_set(&newsk->sk_cookie,
> > atomic64_read(&inet_rsk(req)->ir_cookie));
> >
>
> I think IPv6 needs this too?
>
> diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
> index aeb9497..b3611d9 100644
> --- a/net/ipv6/tcp_ipv6.c
> +++ b/net/ipv6/tcp_ipv6.c
> @@ -1062,6 +1062,7 @@ static struct sock *tcp_v6_syn_recv_sock(const
> struct sock *sk, struct sk_buff *
> newtp->af_specific = &tcp_sock_ipv6_mapped_specific;
> #endif
>
> + newnp->ipv6_mc_list = NULL;
> newnp->ipv6_ac_list = NULL;
> newnp->ipv6_fl_list = NULL;
> newnp->pktoptions = NULL;
Good point, but it looks like you patched on only IPv4 mapped sockets.
And DCCP would need fixes as well.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-05-09 22:51 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-09 12:17 [PATCH net] tcp: do not inherit mc_list from parent Eric Dumazet
2017-05-09 13:23 ` Eric Dumazet
2017-05-09 13:30 ` David Miller
2017-05-09 13:29 ` [PATCH v2 net] dccp/tcp: " Eric Dumazet
2017-05-09 19:18 ` David Miller
2017-05-09 22:37 ` Cong Wang
2017-05-09 22:51 ` Eric Dumazet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).