Re: [PATCH net] net/tcp: Disable TCP-AO static key after RCU grace period

From: Dmitry Safonov
Date: Sat Jul 27 2024 - 14:30:23 EST


Hi Jakub,

On Sat, 27 Jul 2024 at 03:34, Jakub Kicinski <kuba@xxxxxxxxxx> wrote:
>
> On Thu, 25 Jul 2024 06:00:02 +0100 Dmitry Safonov via B4 Relay wrote:
> > @@ -290,9 +298,7 @@ void tcp_ao_destroy_sock(struct sock *sk, bool twsk)
> > atomic_sub(tcp_ao_sizeof_key(key), &sk->sk_omem_alloc);
> > call_rcu(&key->rcu, tcp_ao_key_free_rcu);
> > }
> > -
> > - kfree_rcu(ao, rcu);
> > - static_branch_slow_dec_deferred(&tcp_ao_needed);
> > + call_rcu(&ao->rcu, tcp_ao_info_free_rcu);
>
> Maybe free the keys inside tcp_ao_info_free_rcu, too?
> IIUC you're saying that new sock is still looking at this ao under RCU
> protection - messing with the key list feels a tiny bit odd since the
> object is technically "live" until the end of the RCU grace period.

Yeah, I think that's possible.
Looking at it now, I think it also needs
: rcu_assign_pointer(tp->ao_info, NULL)
above, rather than a plain null-assign.

Will fix and send v2.

Thanks,
Dmitry