Skip to content

Commit

Permalink
xfrm: Verify MAC header exists before overwriting eth_hdr(skb)->h_proto
Browse files Browse the repository at this point in the history
Artem Savkov reported that commit 5efec5c leads to a packet loss under
IPSec configuration. It appears that his setup consists of a TUN device,
which does not have a MAC header.

Make sure MAC header exists.

Note: TUN device sets a MAC header pointer, although it does not have one.

Fixes: 5efec5c ("xfrm: Fix eth_hdr(skb)->h_proto to reflect inner IP version")
Reported-by: Artem Savkov <artem.savkov@gmail.com>
Tested-by: Artem Savkov <artem.savkov@gmail.com>
Signed-off-by: Yossi Kuperman <yossiku@mellanox.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
  • Loading branch information
Yossi Kuperman authored and Steffen Klassert committed Mar 7, 2018
1 parent b8b549e commit 87cdf31
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion net/ipv4/xfrm4_mode_tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ static int xfrm4_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)

skb_reset_network_header(skb);
skb_mac_header_rebuild(skb);
eth_hdr(skb)->h_proto = skb->protocol;
if (skb->mac_len)
eth_hdr(skb)->h_proto = skb->protocol;

err = 0;

Expand Down
3 changes: 2 additions & 1 deletion net/ipv6/xfrm6_mode_tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ static int xfrm6_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)

skb_reset_network_header(skb);
skb_mac_header_rebuild(skb);
eth_hdr(skb)->h_proto = skb->protocol;
if (skb->mac_len)
eth_hdr(skb)->h_proto = skb->protocol;

err = 0;

Expand Down

0 comments on commit 87cdf31

Please sign in to comment.