Re: [PATCH] net: Fix suspicious RCU usage in bpf_sk_reuseport_detach()

From: Martin KaFai Lau
Date: Tue Aug 16 2022 - 17:49:54 EST


On Tue, Aug 16, 2022 at 02:09:46PM +0100, David Howells wrote:
> Hawkins Jiawei <yin31149@xxxxxxxxx> wrote:
>
> > if (socks) {
> > WRITE_ONCE(sk->sk_user_data, NULL);
>
> Btw, shouldn't this be rcu_assign_pointer() or RCU_INIT_POINTER(), not
> WRITE_ONCE()?
It is not necessary. The sk_user_data usage in reuseport_array
is protected by the sk_callback_lock alone. The code
before the commit cf8c1e967224 is fine. If the
__rcu_dereference_sk_user_data_with_flags() could be reused here as is,
an extra rcu_dereference is fine, so I did not mention it.
It seems it is not the case and new function naming is getting long,
so how about reverting the commit cf8c1e967224 and keep it as it was.