Skip to content

Commit

Permalink
udp: fix possible user after free in error handler
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Paolo Abeni authored and David S. Miller committed Feb 23, 2019
1 parent 424a7cd commit 92b9536
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions net/ipv4/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,10 +562,12 @@ static int __udp4_lib_err_encap_no_sk(struct sk_buff *skb, u32 info)

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

if (!iptun_encaps[i])
encap = rcu_dereference(iptun_encaps[i]);
if (!encap)
continue;
handler = rcu_dereference(iptun_encaps[i]->err_handler);
handler = encap->err_handler;
if (handler && !handler(skb, info))
return 0;
}
Expand Down

0 comments on commit 92b9536

Please sign in to comment.