tcp: annotate data races in __tcp_oow_rate_limited()
Subsystems (3)
PATCH 1/1 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 <[email protected]>
--- net/ipv4/tcp_input.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
net/ipv4/tcp_input.c +9 -3
@@ -3590,8 +3590,11 @@ static int tcp_ack_update_window(struct sock *sk, const struct sk_buff *skb, u32static bool __tcp_oow_rate_limited (struct net *net,int mib_idx,u32 *last_oow_ack_time) { -if (*last_oow_ack_time) { -s32 elapsed = (s32)(tcp_jiffies32 - *last_oow_ack_time); +/* Paired with the WRITE_ONCE() in this function. */ +u32 val =READ_ONCE (*last_oow_ack_time); + +if (val) { +s32 elapsed = (s32)(tcp_jiffies32 - val);if (0 <= elapsed && elapsed <READ_ONCE (net->ipv4.sysctl_tcp_invalid_ratelimit)) {
@@ -3600,7 +3603,10 @@ static bool __tcp_oow_rate_limited(struct net *net, int mib_idx, } } - *last_oow_ack_time = tcp_jiffies32; +/* Paired with the prior READ_ONCE() and with itself, +* as we might be lockless. +*/ +WRITE_ONCE (*last_oow_ack_time, tcp_jiffies32);return false;/* not rate-limited: go ahead, send dupack now! */ }
Signature · 1 line
2.41.0.255.g8b1d071c50-goog
This patch was applied to netdev/net.git (main) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:
Quoted 9 lines · On Thu, 29 Jun 2023 16:41:50 +0000 you wrote:
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 <[email protected]>[...]
Here is the summary with links:
- [net] tcp: annotate data races in __tcp_oow_rate_limited()
https://git.kernel.org/netdev/net/c/998127cdb469
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html