Skip to content

Commit cf28ff8

Browse files
edumazetkuba-moo
authored andcommitted
ila: block BH in ila_output()
As explained in commit 1378817 ("tipc: block BH before using dst_cache"), net/core/dst_cache.c helpers need to be called with BH disabled. ila_output() is called from lwtunnel_output() possibly from process context, and under rcu_read_lock(). We might be interrupted by a softirq, re-enter ila_output() and corrupt dst_cache data structures. Fix the race by using local_bh_disable(). Signed-off-by: Eric Dumazet <edumazet@google.com> Acked-by: Paolo Abeni <pabeni@redhat.com> Link: https://lore.kernel.org/r/20240531132636.2637995-5-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent c0b98ac commit cf28ff8

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

net/ipv6/ila/ila_lwt.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ static int ila_output(struct net *net, struct sock *sk, struct sk_buff *skb)
5858
return orig_dst->lwtstate->orig_output(net, sk, skb);
5959
}
6060

61+
local_bh_disable();
6162
dst = dst_cache_get(&ilwt->dst_cache);
63+
local_bh_enable();
6264
if (unlikely(!dst)) {
6365
struct ipv6hdr *ip6h = ipv6_hdr(skb);
6466
struct flowi6 fl6;
@@ -86,8 +88,11 @@ static int ila_output(struct net *net, struct sock *sk, struct sk_buff *skb)
8688
goto drop;
8789
}
8890

89-
if (ilwt->connected)
91+
if (ilwt->connected) {
92+
local_bh_disable();
9093
dst_cache_set_ip6(&ilwt->dst_cache, dst, &fl6.saddr);
94+
local_bh_enable();
95+
}
9196
}
9297

9398
skb_dst_set(skb, dst);

0 commit comments

Comments
 (0)