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

netfilter: bridge: call pskb_may_pull in br_nf_check_hbh_len

When checking Hop-by-hop option header, if the option data is in
nonlinear area, it should do pskb_may_pull instead of discarding
the skb as a bad IPv6 packet.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Reviewed-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Florian Westphal <fw@strlen.de>

authored by

Xin Long and committed by
Florian Westphal
9ccff83b 4386b921

+9 -5
+9 -5
net/bridge/br_netfilter_ipv6.c
··· 45 45 */ 46 46 static int br_nf_check_hbh_len(struct sk_buff *skb) 47 47 { 48 - unsigned char *raw = (u8 *)(ipv6_hdr(skb) + 1); 48 + int len, off = sizeof(struct ipv6hdr); 49 + unsigned char *nh; 49 50 u32 pkt_len; 50 - const unsigned char *nh = skb_network_header(skb); 51 - int off = raw - nh; 52 - int len = (raw[1] + 1) << 3; 53 51 54 - if ((raw + len) - skb->data > skb_headlen(skb)) 52 + if (!pskb_may_pull(skb, off + 8)) 55 53 goto bad; 54 + nh = (unsigned char *)(ipv6_hdr(skb) + 1); 55 + len = (nh[1] + 1) << 3; 56 + 57 + if (!pskb_may_pull(skb, off + len)) 58 + goto bad; 59 + nh = skb_network_header(skb); 56 60 57 61 off += 2; 58 62 len -= 2;