Re: [PATCH net 1/2] tcp: initialize ir_rmt_addr and ir_loc_addr in cookie_v6_check()
From: Thaison Phan
Date: Sun Nov 15 2026 - 21:31:21 EST
On Sun, Nov 15, 2026 at 09:06:59AM +0100, Eric Dumazet wrote:
> 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.
I should have explained KASAN's relation to the bug better. It was not caught
by a KASAN/KMSAN report itself, but originally noticed via an out-of-tree
socket hook observing inet_sk(sk)->inet_saddr != LOOPBACK4_IPV6 on KASAN test
runs, and reproduced upstream via the inet_sock_set_state tracepoint.
When KASAN is enabled, SLUB_RCU_DEBUG is enabled by default, introducing an RCU
grace period before freeing the request_sock from the initial SYN. Without that
grace period, cookie_v6_check() typically reuses the warm request_sock whose
ir_rmt_addr and ir_loc_addr were already set to LOOPBACK4_IPV6. With the grace
period, cookie_v6_check() gets a cold slab object instead, e.g. (with
slub_debug=P, expecting 127.0.0.6):
... sock:inet_sock_set_state: family=AF_INET6 protocol=IPPROTO_TCP \
sport=59839 dport=41050 \
saddr=90.90.90.90 daddr=90.90.90.90 \
saddrv6=::1 daddrv6=::1 \
oldstate=TCP_LISTEN newstate=TCP_SYN_RECV
I'll clarify this and include the trace output in the v2 changelog.