On Sun, Nov 29, 2026 at 10:57 PM Paul Moses <…@1g4.org> wrote:
> BUG: KASAN: invalid-free in tcp_cdg_release+0x38/0xac
A route with "congctl cdg" gives the same splat without a race. tcp_ca_dst_init() replaces icsk_ca_ops and keeps the state of the old cc: bpf_module_put(icsk->icsk_ca_ops, icsk->icsk_ca_ops->owner); icsk->icsk_ca_dst_locked = tcp_ca_dst_locked(dst); WRITE_ONCE(icsk->icsk_ca_ops, ca); icsk_ca_priv[2] is ca->gradients in cdg. With TCP_FASTOPEN_CONNECT and TCP_FASTOPEN_NO_COOKIE: connect() TCP_SYN_SENT, tcp_connect() is deferred setsockopt("bpf_cc") ->init() sets icsk_ca_priv[2] = X icsk_ca_initialized = 1 write() tcp_ca_dst_init() sets icsk_ca_ops = cdg SYN-ACK tcp_init_transfer() skips tcp_cdg_init() close() tcp_cdg_release() does kfree(X) tcp_ca_openreq_child() doesn't clear icsk_ca_priv either. bpf_cc->set_state() can write it in tcp_disconnect() before listen(). The child gets a copy and tcp_cdg_init() doesn't reset ca->tail. With tail == 255 tcp_cdg_grad() writes past the end of ca->gradients. Both should reset icsk_ca_priv and icsk_ca_initialized like tcp_reinit_congestion_control() does. pw-bot: cr