Skip to content

Commit c6e108c

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

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

net/ipv4/tcp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4306,7 +4306,7 @@ struct sk_buff *tcp_get_timestamping_opt_stats(const struct sock *sk,
43064306
TCP_NLA_PAD);
43074307
nla_put_u64_64bit(stats, TCP_NLA_BYTES_RETRANS,
43084308
READ_ONCE(tp->bytes_retrans), TCP_NLA_PAD);
4309-
nla_put_u32(stats, TCP_NLA_DSACK_DUPS, tp->dsack_dups);
4309+
nla_put_u32(stats, TCP_NLA_DSACK_DUPS, READ_ONCE(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);
43124312
nla_put_u16(stats, TCP_NLA_TIMEOUT_REHASH, tp->timeout_rehash);

net/ipv4/tcp_input.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@ static u32 tcp_dsack_seen(struct tcp_sock *tp, u32 start_seq,
10591059
else if (tp->tlp_high_seq && tp->tlp_high_seq == end_seq)
10601060
state->flag |= FLAG_DSACK_TLP;
10611061

1062-
tp->dsack_dups += dup_segs;
1062+
WRITE_ONCE(tp->dsack_dups, tp->dsack_dups + dup_segs);
10631063
/* Skip the DSACK if dup segs weren't retransmitted by sender */
10641064
if (tp->dsack_dups > tp->total_retrans)
10651065
return 0;

0 commit comments

Comments
 (0)