[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190927181729.7ep3pp2hiy6l5ixk@kafai-mbp.dhcp.thefacebook.com>
Date: Fri, 27 Sep 2019 18:17:36 +0000
From: Martin Lau <kafai@...com>
To: Eric Dumazet <eric.dumazet@...il.com>
CC: "bpf@...r.kernel.org" <bpf@...r.kernel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
Alexei Starovoitov <ast@...com>,
Daniel Borkmann <daniel@...earbox.net>,
David Miller <davem@...emloft.net>,
Kernel Team <Kernel-team@...com>
Subject: Re: [PATCH bpf] bpf: Fix a race in reuseport_array_free()
On Fri, Sep 27, 2019 at 10:24:49AM -0700, Eric Dumazet wrote:
>
>
> On 9/27/19 9:52 AM, Martin KaFai Lau wrote:
> > In reuseport_array_free(), the rcu_read_lock() cannot ensure sk is still
> > valid. It is because bpf_sk_reuseport_detach() can be called from
> > __sk_destruct() which is invoked through call_rcu(..., __sk_destruct).
>
> We could question why reuseport_detach_sock(sk) is called from __sk_destruct()
> (after the rcu grace period) instead of sk_destruct() ?
Agree. It is another way to fix it.
In this patch, I chose to avoid the need to single out a special treatment for
reuseport_detach_sock() in sk_destruct().
I am happy either way. What do you think?
>
> >
> > This patch takes the reuseport_lock in reuseport_array_free() which
> > is not the fast path. The lock is taken inside the loop in case
> > that the bpf map is big.
> >
> > Signed-off-by: Martin KaFai Lau <kafai@...com>
>
> Fixes: 5dc4c4b7d4e8 ("bpf: Introduce BPF_MAP_TYPE_REUSEPORT_SOCKARRAY")
Ah...missed that. Thanks!
Powered by blists - more mailing lists