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

ipv6: fix crash over flow-based vxlan device

Similar check was added in ip_rcv but not in ipv6_rcv.

BUG: unable to handle kernel NULL pointer dereference at (null)
IP: [<ffffffff81734e0a>] ipv6_rcv+0xfa/0x500
Call Trace:
[<ffffffff816c9786>] ? ip_rcv+0x296/0x400
[<ffffffff817732d2>] ? packet_rcv+0x52/0x410
[<ffffffff8168e99f>] __netif_receive_skb_core+0x63f/0x9a0
[<ffffffffc02b34a0>] ? br_handle_frame_finish+0x580/0x580 [bridge]
[<ffffffff8109912c>] ? update_rq_clock.part.81+0x1c/0x40
[<ffffffff8168ed18>] __netif_receive_skb+0x18/0x60
[<ffffffff8168fa1f>] process_backlog+0x9f/0x150

Fixes: ee122c79d422 (vxlan: Flow based tunneling)
Signed-off-by: Wei-Chun Chao <weichunc@plumgrid.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Wei-Chun Chao and committed by
David S. Miller
48fb6b55 6ac9de5f

+3 -2
+3 -2
net/ipv6/ip6_input.c
··· 45 45 #include <net/addrconf.h> 46 46 #include <net/xfrm.h> 47 47 #include <net/inet_ecn.h> 48 + #include <net/dst_metadata.h> 48 49 49 50 int ip6_rcv_finish(struct sock *sk, struct sk_buff *skb) 50 51 { ··· 56 55 if (ipprot && ipprot->early_demux) 57 56 ipprot->early_demux(skb); 58 57 } 59 - if (!skb_dst(skb)) 58 + if (!skb_valid_dst(skb)) 60 59 ip6_route_input(skb); 61 60 62 61 return dst_input(skb); ··· 99 98 * arrived via the sending interface (ethX), because of the 100 99 * nature of scoping architecture. --yoshfuji 101 100 */ 102 - IP6CB(skb)->iif = skb_dst(skb) ? ip6_dst_idev(skb_dst(skb))->dev->ifindex : dev->ifindex; 101 + IP6CB(skb)->iif = skb_valid_dst(skb) ? ip6_dst_idev(skb_dst(skb))->dev->ifindex : dev->ifindex; 103 102 104 103 if (unlikely(!pskb_may_pull(skb, sizeof(*hdr)))) 105 104 goto err;