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: annotate data-races in tcp_req_diag_fill()

req->num_retrans and rsk_timer.expires are read locklessly,
and can be changed from tcp_rtx_synack().

Add READ_ONCE()/WRITE_ONCE() annotations.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20250828102738.2065992-3-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
8e60447f 9a574257

+3 -3
+2 -2
net/ipv4/tcp_diag.c
··· 248 248 inet_diag_msg_common_fill(r, sk); 249 249 r->idiag_state = TCP_SYN_RECV; 250 250 r->idiag_timer = 1; 251 - r->idiag_retrans = reqsk->num_retrans; 251 + r->idiag_retrans = READ_ONCE(reqsk->num_retrans); 252 252 253 253 BUILD_BUG_ON(offsetof(struct inet_request_sock, ir_cookie) != 254 254 offsetof(struct sock, sk_cookie)); 255 255 256 - tmo = inet_reqsk(sk)->rsk_timer.expires - jiffies; 256 + tmo = READ_ONCE(inet_reqsk(sk)->rsk_timer.expires) - jiffies; 257 257 r->idiag_expires = jiffies_delta_to_msecs(tmo); 258 258 r->idiag_rqueue = 0; 259 259 r->idiag_wqueue = 0;
+1 -1
net/ipv4/tcp_output.c
··· 4438 4438 tcp_sk_rw(sk)->total_retrans++; 4439 4439 } 4440 4440 trace_tcp_retransmit_synack(sk, req); 4441 - req->num_retrans++; 4441 + WRITE_ONCE(req->num_retrans, req->num_retrans + 1); 4442 4442 } 4443 4443 return res; 4444 4444 }