Skip to content

Commit 8bd4ce7

Browse files
edumazetgregkh
authored andcommitted
tcp: annotate data-races around tp->bytes_retrans
[ Upstream commit 5efc7b9 ] tcp_get_timestamping_opt_stats() intentionally runs lockless, we must add READ_ONCE() and WRITE_ONCE() annotations to keep KCSAN happy. Fixes: fb31c9b ("tcp: add data bytes retransmitted stats") Signed-off-by: Eric Dumazet <edumazet@google.com> Link: https://patch.msgid.link/20260416200319.3608680-9-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 5e7390e commit 8bd4ce7

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

net/ipv4/tcp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4304,8 +4304,8 @@ struct sk_buff *tcp_get_timestamping_opt_stats(const struct sock *sk,
43044304

43054305
nla_put_u64_64bit(stats, TCP_NLA_BYTES_SENT, READ_ONCE(tp->bytes_sent),
43064306
TCP_NLA_PAD);
4307-
nla_put_u64_64bit(stats, TCP_NLA_BYTES_RETRANS, tp->bytes_retrans,
4308-
TCP_NLA_PAD);
4307+
nla_put_u64_64bit(stats, TCP_NLA_BYTES_RETRANS,
4308+
READ_ONCE(tp->bytes_retrans), TCP_NLA_PAD);
43094309
nla_put_u32(stats, TCP_NLA_DSACK_DUPS, tp->dsack_dups);
43104310
nla_put_u32(stats, TCP_NLA_REORD_SEEN, tp->reord_seen);
43114311
nla_put_u32(stats, TCP_NLA_SRTT, tp->srtt_us >> 3);

net/ipv4/tcp_output.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3414,7 +3414,7 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs)
34143414
if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN)
34153415
__NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPSYNRETRANS);
34163416
WRITE_ONCE(tp->total_retrans, tp->total_retrans + segs);
3417-
tp->bytes_retrans += skb->len;
3417+
WRITE_ONCE(tp->bytes_retrans, tp->bytes_retrans + skb->len);
34183418

34193419
/* make sure skb->data is aligned on arches that require it
34203420
* and check if ack-trimming & collapsing extended the headroom

0 commit comments

Comments
 (0)