Skip to content

Commit

Permalink
ipv6: xfrm: Handle errors reported by xfrm6_find_1stfragopt()
Browse files Browse the repository at this point in the history
xfrm6_find_1stfragopt() may now return an error code and we must
not treat it as a length.

Fixes: 2423496 ("ipv6: Prevent overrun when parsing v6 header options")
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Acked-by: Craig Gallek <kraig@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Ben Hutchings authored and David S. Miller committed Jun 2, 2017
1 parent 13fb6c2 commit 6e80ac5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions net/ipv6/xfrm6_mode_ro.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ static int xfrm6_ro_output(struct xfrm_state *x, struct sk_buff *skb)
iph = ipv6_hdr(skb);

hdr_len = x->type->hdr_offset(x, skb, &prevhdr);
if (hdr_len < 0)
return hdr_len;
skb_set_mac_header(skb, (prevhdr - x->props.header_len) - skb->data);
skb_set_network_header(skb, -x->props.header_len);
skb->transport_header = skb->network_header + hdr_len;
Expand Down
2 changes: 2 additions & 0 deletions net/ipv6/xfrm6_mode_transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ static int xfrm6_transport_output(struct xfrm_state *x, struct sk_buff *skb)
skb_set_inner_transport_header(skb, skb_transport_offset(skb));

hdr_len = x->type->hdr_offset(x, skb, &prevhdr);
if (hdr_len < 0)
return hdr_len;
skb_set_mac_header(skb, (prevhdr - x->props.header_len) - skb->data);
skb_set_network_header(skb, -x->props.header_len);
skb->transport_header = skb->network_header + hdr_len;
Expand Down

0 comments on commit 6e80ac5

Please sign in to comment.