๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by Eric Dumazet Sun, 15 Nov 2026 08:13
Re: [PATCH net 2/2] tcp: accecn: initialize AccECN fields in syncookie path
#16575
Author: Eric Dumazet
Date: Sun, 15 Nov 2026 08:13
100 lines
13033 bytes
Le sam. 14 nov. 2026 ร  17:13, Thaison Phan <thaisonphan@google.com> a รฉcrit :
>
> cookie_tcp_reqsk_alloc() and bpf_sk_assign_tcp_reqsk() allocate struct
> request_sock without __GFP_ZERO, leaving saw_accecn_opt,
> accecn_fail_mode, syn_ect_rcv, and syn_ect_snt uninitialized. When
> accecn_ok is negotiated in cookie_{v4,v6}_check(),
> tcp_ecn_openreq_child() reads all four fields to initialize the child
> socket's AccECN state.
>

Right.

> In addition, because the temporary request_sock used to send a cookie
> SYN-ACK is immediately freed, treq->syn_ect_snt is lost. If the listener
> marks ECT (e.g. DCTCP), leaving syn_ect_snt at 0 causes
> tcp_accecn_third_ack() to flag TCP_ACCECN_ACE_FAIL_RECV when the peer
> reflects ECT, disabling ECT for the rest of the connection.

This is a different bug than the uninitialized fields above, with
a different impact. I would prefer two patches, one per bug, but
since both Fixes: commits landed in the same release I will not
insist.

>
> Initialize the AccECN fields in cookie_tcp_reqsk_init() to match
> tcp_openreq_init(), and set syn_ect_snt from the listener's TOS/tclass
> in cookie_{v4,v6}_check() to match tcp_{v4,v6}_send_synack().
>
> Found by code inspection while auditing request_sock initialization in
> the syncookie path; reproduced without kernel modifications in a KASAN
> VM (tcp_syncookies=2, tcp_ecn=3) and tested against the reproducer and
> packetdrill AccECN/syncookie selftests.

Same remark as for the LOOPBACK4_IPV6 patch: KASAN does not catch
uninitialized bitfields. Please say how the failure was observed
(KMSAN, tcpi_accecn_fail_mode in TCP_INFO on the child, ...).

>
> Fixes: 3cae34274c79 ("tcp: accecn: AccECN negotiation")
> Fixes: b40671b5ee58 ("tcp: accecn: AccECN option failure handling")
> Signed-off-by: Thaison Phan <thaisonphan@google.com>
> ---
>  net/ipv4/syncookies.c | 5 +++++
>  net/ipv6/syncookies.c | 1 +
>  2 files changed, 6 insertions(+)
>
> diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
> index 4e0ff3b82062..5747f9a5a6d1 100644
> --- a/net/ipv4/syncookies.c
> +++ b/net/ipv4/syncookies.c
> @@ -290,6 +290,10 @@ static int cookie_tcp_reqsk_init(struct sock *sk, struct sk_buff *skb,
>          */
>         treq->txhash = treq->snt_isn;
>         treq->syn_tos = TCP_SKB_CB(skb)->ip_dsfield;
> +       treq->saw_accecn_opt = TCP_ACCECN_OPT_NOT_SEEN;
> +       treq->accecn_fail_mode = 0;
> +       treq->syn_ect_rcv = 0;
> +       treq->syn_ect_snt = 0;

I think syn_ect_snt is always overwritten in cookie_{v4,v6}_check()
before being read, this line is not needed?

>
>  #if IS_ENABLED(CONFIG_MPTCP)
>         treq->is_mptcp = sk_is_mptcp(sk);
> @@ -502,6 +506,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb)
>                 ireq->rcv_wscale = rcv_wscale;
>         ireq->ecn_ok &= cookie_ecn_ok(net, &rt->dst);
>         treq->accecn_ok = ireq->ecn_ok && cookie_accecn_ok(th);
> +       treq->syn_ect_snt = READ_ONCE(inet_sk(sk)->tos) & INET_ECN_MASK;
>
>         ret = tcp_get_cookie_sock(sk, skb, req, &rt->dst);
>         /* ip_queue_xmit() depends on our flow being setup
> diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c
> index b33011b71fff..7435ebcc366c 100644
> --- a/net/ipv6/syncookies.c
> +++ b/net/ipv6/syncookies.c
> @@ -276,6 +276,7 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
>                 ireq->rcv_wscale = rcv_wscale;
>         ireq->ecn_ok &= cookie_ecn_ok(net, dst);
>         tcp_rsk(req)->accecn_ok = ireq->ecn_ok && cookie_accecn_ok(th);
> +       tcp_rsk(req)->syn_ect_snt = READ_ONCE(np->tclass) & INET_ECN_MASK;
>
>         ret = tcp_get_cookie_sock(sk, skb, req, dst);
>         if (!ret) {
> --
> 2.56.0.611.g1030f0b940-goog
>

Reviewed-by: Eric Dumazet <edumazet@kernel.org>

Thanks.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads