Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tcp: use WRITE_ONCE() for tsoffset in tcp_v6_connect()

Commit dd23c9f1e8d5 ("tcp: annotate data-races around tp->tsoffset")
updated do_tcp_getsockopt() to read tp->tsoffset with READ_ONCE()
for TCP_TIMESTAMP because another CPU may change it concurrently.

tcp_v6_connect() still stores tp->tsoffset with a plain write. That
store runs under lock_sock() via inet_stream_connect(), but the socket
lock does not serialize a concurrent getsockopt(TCP_TIMESTAMP) from
another task sharing the socket.

Use WRITE_ONCE() for the tcp_v6_connect() store so the connect-time
writer matches the lockless TCP_TIMESTAMP reader. This also makes the
IPv6 path consistent with tcp_v4_connect().

Signed-off-by: Wesley Atwell <atwellwea@gmail.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Jiayuan Chen <jiayuan.chen@shopee.com>
Link: https://patch.msgid.link/20260310012604.145661-1-atwellwea@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Wesley Atwell and committed by
Jakub Kicinski
dc9902bb 87aa0f53

+1 -1
+1 -1
net/ipv6/tcp_ipv6.c
··· 325 325 inet->inet_dport); 326 326 if (!tp->write_seq) 327 327 WRITE_ONCE(tp->write_seq, st.seq); 328 - tp->tsoffset = st.ts_off; 328 + WRITE_ONCE(tp->tsoffset, st.ts_off); 329 329 } 330 330 331 331 if (tcp_fastopen_defer_connect(sk, &err))