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() ? > > 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@xxxxxx> Fixes: 5dc4c4b7d4e8 ("bpf: Introduce BPF_MAP_TYPE_REUSEPORT_SOCKARRAY")