mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-28 05:12:49 +00:00
tcp: annotate data races in __tcp_oow_rate_limited()
[ Upstream commit998127cdb4
] 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:4ce7e93cb3
("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
0dad52a840
commit
428ccde924
1 changed files with 9 additions and 3 deletions
|
@ -3584,8 +3584,11 @@ static int tcp_ack_update_window(struct sock *sk, const struct sk_buff *skb, u32
|
||||||
static bool __tcp_oow_rate_limited(struct net *net, int mib_idx,
|
static bool __tcp_oow_rate_limited(struct net *net, int mib_idx,
|
||||||
u32 *last_oow_ack_time)
|
u32 *last_oow_ack_time)
|
||||||
{
|
{
|
||||||
if (*last_oow_ack_time) {
|
/* Paired with the WRITE_ONCE() in this function. */
|
||||||
s32 elapsed = (s32)(tcp_jiffies32 - *last_oow_ack_time);
|
u32 val = READ_ONCE(*last_oow_ack_time);
|
||||||
|
|
||||||
|
if (val) {
|
||||||
|
s32 elapsed = (s32)(tcp_jiffies32 - val);
|
||||||
|
|
||||||
if (0 <= elapsed &&
|
if (0 <= elapsed &&
|
||||||
elapsed < READ_ONCE(net->ipv4.sysctl_tcp_invalid_ratelimit)) {
|
elapsed < READ_ONCE(net->ipv4.sysctl_tcp_invalid_ratelimit)) {
|
||||||
|
@ -3594,7 +3597,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! */
|
return false; /* not rate-limited: go ahead, send dupack now! */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue