Patch "ip_gre: validate csum_start only on pull" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    ip_gre: validate csum_start only on pull

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     ip_gre-validate-csum_start-only-on-pull.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 47a11ef23024c58533abd8255ad72f3e69786483
Author: Willem de Bruijn <willemb@xxxxxxxxxx>
Date:   Sun Sep 5 11:21:09 2021 -0400

    ip_gre: validate csum_start only on pull
    
    [ Upstream commit 8a0ed250f911da31a2aef52101bc707846a800ff ]
    
    The GRE tunnel device can pull existing outer headers in ipge_xmit.
    This is a rare path, apparently unique to this device. The below
    commit ensured that pulling does not move skb->data beyond csum_start.
    
    But it has a false positive if ip_summed is not CHECKSUM_PARTIAL and
    thus csum_start is irrelevant.
    
    Refine to exclude this. At the same time simplify and strengthen the
    test.
    
    Simplify, by moving the check next to the offending pull, making it
    more self documenting and removing an unnecessary branch from other
    code paths.
    
    Strengthen, by also ensuring that the transport header is correct and
    therefore the inner headers will be after skb_reset_inner_headers.
    The transport header is set to csum_start in skb_partial_csum_set.
    
    Link: https://lore.kernel.org/netdev/YS+h%2FtqCJJiQei+W@shredder/
    Fixes: 1d011c4803c7 ("ip_gre: add validation for csum_start")
    Reported-by: Ido Schimmel <idosch@xxxxxxxxxx>
    Suggested-by: Alexander Duyck <alexander.duyck@xxxxxxxxx>
    Signed-off-by: Willem de Bruijn <willemb@xxxxxxxxxx>
    Reviewed-by: Alexander Duyck <alexanderduyck@xxxxxx>
    Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index a0829495b211..a9cc05043fa4 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -468,8 +468,6 @@ static void __gre_xmit(struct sk_buff *skb, struct net_device *dev,
 
 static int gre_handle_offloads(struct sk_buff *skb, bool csum)
 {
-	if (csum && skb_checksum_start(skb) < skb->data)
-		return -EINVAL;
 	return iptunnel_handle_offloads(skb, csum ? SKB_GSO_GRE_CSUM : SKB_GSO_GRE);
 }
 
@@ -627,15 +625,20 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,
 	}
 
 	if (dev->header_ops) {
+		const int pull_len = tunnel->hlen + sizeof(struct iphdr);
+
 		if (skb_cow_head(skb, 0))
 			goto free_skb;
 
 		tnl_params = (const struct iphdr *)skb->data;
 
+		if (pull_len > skb_transport_offset(skb))
+			goto free_skb;
+
 		/* Pull skb since ip_tunnel_xmit() needs skb->data pointing
 		 * to gre header.
 		 */
-		skb_pull(skb, tunnel->hlen + sizeof(struct iphdr));
+		skb_pull(skb, pull_len);
 		skb_reset_mac_header(skb);
 	} else {
 		if (skb_cow_head(skb, dev->needed_headroom))



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux