Skip to content

Commit 87cdf31

Browse files
Yossi Kupermanklassert
Yossi Kuperman
authored andcommitted
xfrm: Verify MAC header exists before overwriting eth_hdr(skb)->h_proto
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 <[email protected]> Tested-by: Artem Savkov <[email protected]> Signed-off-by: Yossi Kuperman <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent b8b549e commit 87cdf31

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

net/ipv4/xfrm4_mode_tunnel.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ static int xfrm4_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
9292

9393
skb_reset_network_header(skb);
9494
skb_mac_header_rebuild(skb);
95-
eth_hdr(skb)->h_proto = skb->protocol;
95+
if (skb->mac_len)
96+
eth_hdr(skb)->h_proto = skb->protocol;
9697

9798
err = 0;
9899

net/ipv6/xfrm6_mode_tunnel.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ static int xfrm6_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb)
9292

9393
skb_reset_network_header(skb);
9494
skb_mac_header_rebuild(skb);
95-
eth_hdr(skb)->h_proto = skb->protocol;
95+
if (skb->mac_len)
96+
eth_hdr(skb)->h_proto = skb->protocol;
9697

9798
err = 0;
9899

0 commit comments

Comments
 (0)