On Fri, Dec 04, 2026 at 08:50 PM Paul Moses <…@1g4.org> wrote:
> 1. The LSM hook selects nv and runs tcpnv_init() with bpf_chg_cc_inprogress > set. The nested CA change returns -EBUSY. > 2. Patch 2 clears icsk_ca_initialized in tcp_ca_openreq_child(). > 3. tcp_init_transfer() calls tcpnv_init() again, this time without the guard > set. > 4. The nested CA change succeeds, but tcpnv_init() continues writing to > icsk_ca_priv after the CA has been replaced, corrupting the new CA's state.
The steps are correct, but step 4 is the bug. It doesn't need steps 1-3. bpf_chg_cc_inprogress is set only when bpf_setsockopt() selects nv. Every other way to select nv runs tcpnv_init() without it. Remove the lsm prog and keep the sockops prog: setsockopt(lfd, TCP_CONGESTION, "nv") before listen() tcp_init_transfer() of the child bpf_chg_cc_inprogress == 0 tcpnv_init() BPF_SOCK_OPS_BASE_RTT prog bpf_setsockopt("highspeed") hstcp_init(): ca->ai = 0 ca->nv_min_rtt_reset_jiffies = jiffies + 2 * HZ <- ca->ai hstcp_cong_avoid() hstcp_aimd_vals[ca->ai] <- oops Both fields are at offset 0 of icsk_ca_priv.
> This does not happen on unpatched or with [2] applied.
This sequence is the same on all three kernels. It's the issue from [3]: ->init() writes icsk_ca_priv after bpf_setsockopt() returns. Here ->init() is tcpnv_init(). It needs its own fix. bpf_sock_ops_setsockopt() can refuse TCP_CONGESTION in BPF_SOCK_OPS_BASE_RTT, like it refuses TCP_NODELAY in BPF_SOCK_OPS_HDR_OPT_LEN_CB.
> What about oot modules? bpf is incredibly intricate and I'd imagine is forced > to be less considerate, but it's less the case for net.
Out of tree modules are not a concern. That's the same in net. sol_tcp_sockopt_congestion() refuses "cdg" by name. An oot cc with a pointer in icsk_ca_priv is not on that list. A bpf cc can switch to it and overwrite the pointer today.
be5d1b61a2ad fixed a leak in cdg. User space sets cdg in TCP_SYN_SENT. The 2nd tcp_cdg_init() loses ca->gradients. Only the lsm prog runs between the clone and tcp_ca_openreq_child(). It can't set cdg. Nothing changes for patch 2.