ip_tunnel: annotate data-races around t->err_count and t->err_time
ip_tunnel_xmit() runs locklessly (dev->lltx == true). ipgre_err() and ipip_err() also run locklessly. We need to add READ_ONCE() and WRITE_ONCE() annotations around t->err_count and t->err_time. Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20260611165247.2710257-1-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
1 parent
8058d9755e
commit
80a7e3507d
3 files changed
+16
-13
No files matched your search
+4
-4
@@ -207,11 +207,11 @@ static int ipgre_err(struct sk_buff *skb, u32 info,
|
||||
if (t->parms.iph.ttl == 0 && type == ICMP_TIME_EXCEEDED)
|
||||
return 0;
|
||||
|
||||
if (time_before(jiffies, t->err_time + IPTUNNEL_ERR_TIMEO))
|
||||
t->err_count++;
|
||||
if (time_before(jiffies, READ_ONCE(t->err_time) + IPTUNNEL_ERR_TIMEO))
|
||||
WRITE_ONCE(t->err_count, READ_ONCE(t->err_count) + 1);
|
||||
else
|
||||
t->err_count = 1;
|
||||
t->err_time = jiffies;
|
||||
WRITE_ONCE(t->err_count, 1);
|
||||
WRITE_ONCE(t->err_time, jiffies);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -679,6 +679,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
|
||||
struct flowi4 fl4;
|
||||
bool md = false;
|
||||
bool connected;
|
||||
int err_count;
|
||||
u8 tos, ttl;
|
||||
__be32 dst;
|
||||
__be16 df;
|
||||
@@ -807,14 +808,16 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
|
||||
goto tx_error;
|
||||
}
|
||||
|
||||
if (tunnel->err_count > 0) {
|
||||
err_count = READ_ONCE(tunnel->err_count);
|
||||
if (err_count > 0) {
|
||||
if (time_before(jiffies,
|
||||
tunnel->err_time + IPTUNNEL_ERR_TIMEO)) {
|
||||
tunnel->err_count--;
|
||||
READ_ONCE(tunnel->err_time) + IPTUNNEL_ERR_TIMEO)) {
|
||||
WRITE_ONCE(tunnel->err_count, err_count - 1);
|
||||
|
||||
dst_link_failure(skb);
|
||||
} else
|
||||
tunnel->err_count = 0;
|
||||
} else {
|
||||
WRITE_ONCE(tunnel->err_count, 0);
|
||||
}
|
||||
}
|
||||
|
||||
tos = ip_tunnel_ecn_encap(tos, inner_iph, skb);
|
||||
|
||||
+4
-4
@@ -190,11 +190,11 @@ static int ipip_err(struct sk_buff *skb, u32 info)
|
||||
if (t->parms.iph.ttl == 0 && type == ICMP_TIME_EXCEEDED)
|
||||
goto out;
|
||||
|
||||
if (time_before(jiffies, t->err_time + IPTUNNEL_ERR_TIMEO))
|
||||
t->err_count++;
|
||||
if (time_before(jiffies, READ_ONCE(t->err_time) + IPTUNNEL_ERR_TIMEO))
|
||||
WRITE_ONCE(t->err_count, READ_ONCE(t->err_count) + 1);
|
||||
else
|
||||
t->err_count = 1;
|
||||
t->err_time = jiffies;
|
||||
WRITE_ONCE(t->err_count, 1);
|
||||
WRITE_ONCE(t->err_time, jiffies);
|
||||
|
||||
out:
|
||||
return err;
|
||||
|
||||
Reference in new issue
Block a user