lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 20 Aug 2020 08:28:22 -0400
From:   Miaohe Lin <linmiaohe@...wei.com>
To:     <davem@...emloft.net>, <kuba@...nel.org>,
        <martin.varghese@...ia.com>, <pshelar@....org>, <fw@...len.de>,
        <dcaratti@...hat.com>, <edumazet@...gle.com>,
        <steffen.klassert@...unet.com>, <pabeni@...hat.com>,
        <shmulik@...anetworks.com>, <kyk.segfault@...il.com>
CC:     <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <linmiaohe@...wei.com>
Subject: [PATCH] net: Check the expect of skb->data at mac header

skb_mpls_push() and skb_mpls_pop() expect skb->data at mac header. Check
this assumption or we would get wrong mac_header and network_header.

Signed-off-by: Miaohe Lin <linmiaohe@...wei.com>
---
 net/core/skbuff.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index e18184ffa9c3..52d2ad54aa97 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -5590,6 +5590,7 @@ static void skb_mod_eth_type(struct sk_buff *skb, struct ethhdr *hdr,
 int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto,
 		  int mac_len, bool ethernet)
 {
+	int offset = skb->data - skb_mac_header(skb);
 	struct mpls_shim_hdr *lse;
 	int err;
 
@@ -5600,6 +5601,9 @@ int skb_mpls_push(struct sk_buff *skb, __be32 mpls_lse, __be16 mpls_proto,
 	if (skb->encapsulation)
 		return -EINVAL;
 
+	if (WARN_ONCE(offset, "We got skb with skb->data not at mac header (offset %d)\n", offset))
+		return -EINVAL;
+
 	err = skb_cow_head(skb, MPLS_HLEN);
 	if (unlikely(err))
 		return err;
@@ -5643,11 +5647,15 @@ EXPORT_SYMBOL_GPL(skb_mpls_push);
 int skb_mpls_pop(struct sk_buff *skb, __be16 next_proto, int mac_len,
 		 bool ethernet)
 {
+	int offset = skb->data - skb_mac_header(skb);
 	int err;
 
 	if (unlikely(!eth_p_mpls(skb->protocol)))
 		return 0;
 
+	if (WARN_ONCE(offset, "We got skb with skb->data not at mac header (offset %d)\n", offset))
+		return -EINVAL;
+
 	err = skb_ensure_writable(skb, mac_len + MPLS_HLEN);
 	if (unlikely(err))
 		return err;
-- 
2.19.1

Powered by blists - more mailing lists