Re: [PATCH bpf] bpf: Fix a race in reuseport_array_free()

2019-09-27 Thread Martin Lau
On Fri, Sep 27, 2019 at 01:47:32PM -0700, Eric Dumazet wrote: > > > On 9/27/19 11:17 AM, Martin Lau wrote: > > 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 ensur

Re: [PATCH bpf] bpf: Fix a race in reuseport_array_free()

2019-09-27 Thread Eric Dumazet
On 9/27/19 11:17 AM, Martin Lau wrote: > 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 call

Re: [PATCH bpf] bpf: Fix a race in reuseport_array_free()

2019-09-27 Thread Martin Lau
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

Re: [PATCH bpf] bpf: Fix a race in reuseport_array_free()

2019-09-27 Thread Eric Dumazet
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_de

[PATCH bpf] bpf: Fix a race in reuseport_array_free()

2019-09-27 Thread Martin KaFai Lau
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). This patch takes the reuseport_lock in reuseport_array_free() which is not the fast pat