Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ila: block BH in ila_output()

As explained in commit 1378817486d6 ("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>

authored by

Eric Dumazet and committed by
Jakub Kicinski
cf28ff8e c0b98ac1

+6 -1
+6 -1
net/ipv6/ila/ila_lwt.c
··· 58 58 return orig_dst->lwtstate->orig_output(net, sk, skb); 59 59 } 60 60 61 + local_bh_disable(); 61 62 dst = dst_cache_get(&ilwt->dst_cache); 63 + local_bh_enable(); 62 64 if (unlikely(!dst)) { 63 65 struct ipv6hdr *ip6h = ipv6_hdr(skb); 64 66 struct flowi6 fl6; ··· 88 86 goto drop; 89 87 } 90 88 91 - if (ilwt->connected) 89 + if (ilwt->connected) { 90 + local_bh_disable(); 92 91 dst_cache_set_ip6(&ilwt->dst_cache, dst, &fl6.saddr); 92 + local_bh_enable(); 93 + } 93 94 } 94 95 95 96 skb_dst_set(skb, dst);