Skip to content

Commit 92b9536

Browse files
Paolo Abenidavem330
authored andcommitted
udp: fix possible user after free in error handler
Similar to the previous commit, this addresses the same issue for ipv4: use a single fetch operation and use the correct rcu annotation. Fixes: e7cc082 ("udp: Support for error handlers of tunnels with arbitrary destination port") Signed-off-by: Paolo Abeni <pabeni@redhat.com> Acked-by: Stefano Brivio <sbrivio@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 424a7cd commit 92b9536

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

net/ipv4/udp.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,10 +562,12 @@ static int __udp4_lib_err_encap_no_sk(struct sk_buff *skb, u32 info)
562562

563563
for (i = 0; i < MAX_IPTUN_ENCAP_OPS; i++) {
564564
int (*handler)(struct sk_buff *skb, u32 info);
565+
const struct ip_tunnel_encap_ops *encap;
565566

566-
if (!iptun_encaps[i])
567+
encap = rcu_dereference(iptun_encaps[i]);
568+
if (!encap)
567569
continue;
568-
handler = rcu_dereference(iptun_encaps[i]->err_handler);
570+
handler = encap->err_handler;
569571
if (handler && !handler(skb, info))
570572
return 0;
571573
}

0 commit comments

Comments
 (0)