Skip to content

Commit

Permalink
netfilter: bridge: call pskb_may_pull in br_nf_check_hbh_len
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Xin Long authored and Florian Westphal committed Mar 8, 2023
1 parent 4386b92 commit 9ccff83
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions net/bridge/br_netfilter_ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,18 @@
*/
static int br_nf_check_hbh_len(struct sk_buff *skb)
{
unsigned char *raw = (u8 *)(ipv6_hdr(skb) + 1);
int len, off = sizeof(struct ipv6hdr);
unsigned char *nh;
u32 pkt_len;
const unsigned char *nh = skb_network_header(skb);
int off = raw - nh;
int len = (raw[1] + 1) << 3;

if ((raw + len) - skb->data > skb_headlen(skb))
if (!pskb_may_pull(skb, off + 8))
goto bad;
nh = (unsigned char *)(ipv6_hdr(skb) + 1);
len = (nh[1] + 1) << 3;

if (!pskb_may_pull(skb, off + len))
goto bad;
nh = skb_network_header(skb);

off += 2;
len -= 2;
Expand Down

0 comments on commit 9ccff83

Please sign in to comment.