Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by Eric Dumazet
Sun, 15 Nov 2026 08:06
Re: [PATCH net 1/2] tcp: initialize ir_rmt_addr and ir_loc_addr in cookie_v6_check()
Author: Eric Dumazet
Date: Sun, 15 Nov 2026 08:06
Date: Sun, 15 Nov 2026 08:06
65 lines
11524 bytes
11524 bytes
Le sam. 14 nov. 2026 ร 17:13, Thaison Phan <thaisonphan@google.com> a รฉcrit :
>
> Commit a3a128f611a9 ("inet: consolidate inet_csk_clone_lock()") moved
> the LOOPBACK4_IPV6 initialization for passive IPv6 TCP sockets from
> tcp_v6_syn_recv_sock() to tcp_v6_init_req().
>
> IPv6 SYN cookie connections allocate a fresh request_sock without
> __GFP_ZERO and call tcp_v6_syn_recv_sock() without tcp_v6_init_req(),
> leaving ireq->ir_rmt_addr and ireq->ir_loc_addr uninitialized in
> cookie_v6_check(). inet_csk_clone_lock() then copies uninitialized slab
> bytes into sk_daddr, sk_rcv_saddr, and inet_saddr, exposing them to
> tracepoints and bpf_sock and causing inet_daddr != LOOPBACK4_IPV6 checks
> (such as IP_OPTIONS in do_ip_setsockopt()) to misclassify native IPv6
> child sockets as IPv4-mapped.
>
> Initialize ireq->ir_rmt_addr and ireq->ir_loc_addr to LOOPBACK4_IPV6 in
> cookie_v6_check() to match tcp_v6_init_req().
>
> Found in CI testing on a KASAN kernel; reproduced without kernel
> modifications in a KASAN VM (tcp_syncookies=2) and tested against the
> reproducer and packetdrill syncookie selftests.
>
Nice catch, but KASAN does not report uninitialized reads.
Was this KMSAN, or did you notice garbage in the inet_sock_set_state
tracepoint output?
Please say which in the changelog, and include the report or the
trace line if you have one.
> Fixes: a3a128f611a9 ("inet: consolidate inet_csk_clone_lock()")
> Signed-off-by: Thaison Phan <thaisonphan@google.com>
> ---
> net/ipv6/syncookies.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c
> index b581cb1ee2e8..b33011b71fff 100644
> --- a/net/ipv6/syncookies.c
> +++ b/net/ipv6/syncookies.c
> @@ -17,6 +17,7 @@
> #include <net/ipv6.h>
> #include <net/tcp.h>
> #include <net/tcp_ecn.h>
> +#include <net/transp_v6.h>
>
> #define COOKIEBITS 24 /* Upper bits store count */
> #define COOKIEMASK (((__u32)1 << COOKIEBITS) - 1)
> @@ -205,6 +206,8 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
>
> ireq->ir_v6_rmt_addr = ipv6_hdr(skb)->saddr;
> ireq->ir_v6_loc_addr = ipv6_hdr(skb)->daddr;
> + ireq->ir_rmt_addr = LOOPBACK4_IPV6;
> + ireq->ir_loc_addr = LOOPBACK4_IPV6;
With the changelog clarified:
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
pw-bot: cr
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