Skip to content

Commit

Permalink
xfrm6: Fix the nexthdr offset in _decode_session6.
Browse files Browse the repository at this point in the history
xfrm_decode_session() was originally designed for the
usage in the receive path where the correct nexthdr offset
is stored in IP6CB(skb)->nhoff. Over time this function
spread to code that is used in the output path (netfilter,
vti) where IP6CB(skb)->nhoff is not set. As a result, we
get a wrong nexthdr and the upper layer flow informations
are wrong. This can leed to incorrect policy lookups.

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
  • Loading branch information
Steffen Klassert committed Dec 8, 2014
1 parent de3b7a0 commit f855691
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion net/ipv6/xfrm6_policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,14 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
u16 offset = sizeof(*hdr);
struct ipv6_opt_hdr *exthdr;
const unsigned char *nh = skb_network_header(skb);
u8 nexthdr = nh[IP6CB(skb)->nhoff];
u16 nhoff = IP6CB(skb)->nhoff;
int oif = 0;
u8 nexthdr;

if (!nhoff)
nhoff = offsetof(struct ipv6hdr, nexthdr);

nexthdr = nh[nhoff];

if (skb_dst(skb))
oif = skb_dst(skb)->dev->ifindex;
Expand Down

0 comments on commit f855691

Please sign in to comment.