[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <0490137bbc24e95eadf01bed9c31eb1d0a856a21.1693823464.git.sylv@sylv.io>
Date: Mon, 4 Sep 2023 12:32:08 +0200
From: Marcello Sylvester Bauer <email@....codeaurora.org>
To: Steffen Klassert <steffen.klassert@...unet.com>,
Herbert Xu <herbert@...dor.apana.org.au>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
Cc: Marcello Sylvester Bauer <sylv@...v.io>,
netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v2 1/1] xfrm: Use skb_mac_header_was_set() to check for MAC header presence
From: Marcello Sylvester Bauer <sylv@...v.io>
Add skb_mac_header_was_set() in xfrm4_remove_tunnel_encap() and
xfrm6_remove_tunnel_encap() to detect the presence of a MAC header.
This change prevents a kernel page fault on a non-zero mac_len when the
mac_header is not set.
Signed-off-by: Marcello Sylvester Bauer <sylv@...v.io>
---
net/xfrm/xfrm_input.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
index d5ee96789d4b..6d74bfa1e6e8 100644
--- a/net/xfrm/xfrm_input.c
+++ b/net/xfrm/xfrm_input.c
@@ -250,7 +250,7 @@ static int xfrm4_remove_tunnel_encap(struct xfrm_state *x, struct sk_buff *skb)
skb_reset_network_header(skb);
skb_mac_header_rebuild(skb);
- if (skb->mac_len)
+ if (skb->mac_len && skb_mac_header_was_set(skb))
eth_hdr(skb)->h_proto = skb->protocol;
err = 0;
@@ -287,7 +287,7 @@ static int xfrm6_remove_tunnel_encap(struct xfrm_state *x, struct sk_buff *skb)
skb_reset_network_header(skb);
skb_mac_header_rebuild(skb);
- if (skb->mac_len)
+ if (skb->mac_len && skb_mac_header_was_set(skb))
eth_hdr(skb)->h_proto = skb->protocol;
err = 0;
--
2.42.0
Powered by blists - more mailing lists