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_oow_rate_limited()

request sockets are lockless, __tcp_oow_rate_limited() could be called
on the same object from different cpus. This is harmless.

Add READ_ONCE()/WRITE_ONCE() annotations to avoid a KCSAN report.

Fixes: 4ce7e93cb3fe ("tcp: rate limit ACK sent by SYN_RECV request sockets")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric Dumazet and committed by
David S. Miller
998127cd c94683ed

+9 -3
+9 -3
net/ipv4/tcp_input.c
··· 3590 3590 static bool __tcp_oow_rate_limited(struct net *net, int mib_idx, 3591 3591 u32 *last_oow_ack_time) 3592 3592 { 3593 - if (*last_oow_ack_time) { 3594 - s32 elapsed = (s32)(tcp_jiffies32 - *last_oow_ack_time); 3593 + /* Paired with the WRITE_ONCE() in this function. */ 3594 + u32 val = READ_ONCE(*last_oow_ack_time); 3595 + 3596 + if (val) { 3597 + s32 elapsed = (s32)(tcp_jiffies32 - val); 3595 3598 3596 3599 if (0 <= elapsed && 3597 3600 elapsed < READ_ONCE(net->ipv4.sysctl_tcp_invalid_ratelimit)) { ··· 3603 3600 } 3604 3601 } 3605 3602 3606 - *last_oow_ack_time = tcp_jiffies32; 3603 + /* Paired with the prior READ_ONCE() and with itself, 3604 + * as we might be lockless. 3605 + */ 3606 + WRITE_ONCE(*last_oow_ack_time, tcp_jiffies32); 3607 3607 3608 3608 return false; /* not rate-limited: go ahead, send dupack now! */ 3609 3609 }