Skip to content

Commit 8c70521

Browse files
edumazetkuba-moo
authored andcommitted
tcp: annotate data-race around challenge_timestamp
challenge_timestamp can be read an written by concurrent threads. This was expected, but we need to annotate the race to avoid potential issues. Following patch moves challenge_timestamp and challenge_count to per-netns storage to provide better isolation. Fixes: 354e4aa ("tcp: RFC 5961 5.2 Blind Data Injection Attack Mitigation") Reported-by: syzbot <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Acked-by: Neal Cardwell <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 52267ce commit 8c70521

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/ipv4/tcp_input.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3629,11 +3629,11 @@ static void tcp_send_challenge_ack(struct sock *sk)
36293629

36303630
/* Then check host-wide RFC 5961 rate limit. */
36313631
now = jiffies / HZ;
3632-
if (now != challenge_timestamp) {
3632+
if (now != READ_ONCE(challenge_timestamp)) {
36333633
u32 ack_limit = READ_ONCE(net->ipv4.sysctl_tcp_challenge_ack_limit);
36343634
u32 half = (ack_limit + 1) >> 1;
36353635

3636-
challenge_timestamp = now;
3636+
WRITE_ONCE(challenge_timestamp, now);
36373637
WRITE_ONCE(challenge_count, half + prandom_u32_max(ack_limit));
36383638
}
36393639
count = READ_ONCE(challenge_count);

0 commit comments

Comments
 (0)