Patch "ipv4: ip_gre: Avoid skb_pull() failure in ipgre_xmit()" has been added to the 5.4-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

    ipv4: ip_gre: Avoid skb_pull() failure in ipgre_xmit()

to the 5.4-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:
     ipv4-ip_gre-avoid-skb_pull-failure-in-ipgre_xmit.patch
and it can be found in the queue-5.4 subdirectory.

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



commit 3eb8cb022ac5e64bf5a872ede5079c0b753f355f
Author: Shigeru Yoshida <syoshida@xxxxxxxxxx>
Date:   Sun Dec 3 01:14:41 2023 +0900

    ipv4: ip_gre: Avoid skb_pull() failure in ipgre_xmit()
    
    [ Upstream commit 80d875cfc9d3711a029f234ef7d680db79e8fa4b ]
    
    In ipgre_xmit(), skb_pull() may fail even if pskb_inet_may_pull() returns
    true. For example, applications can use PF_PACKET to create a malformed
    packet with no IP header. This type of packet causes a problem such as
    uninit-value access.
    
    This patch ensures that skb_pull() can pull the required size by checking
    the skb with pskb_network_may_pull() before skb_pull().
    
    Fixes: c54419321455 ("GRE: Refactor GRE tunneling code.")
    Signed-off-by: Shigeru Yoshida <syoshida@xxxxxxxxxx>
    Reviewed-by: Eric Dumazet <edumazet@xxxxxxxxxx>
    Reviewed-by: Suman Ghosh <sumang@xxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20231202161441.221135-1-syoshida@xxxxxxxxxx
    Signed-off-by: Paolo Abeni <pabeni@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index f8f008344273e..db48dec61f305 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -607,15 +607,18 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,
 	}
 
 	if (dev->header_ops) {
+		int pull_len = tunnel->hlen + sizeof(struct iphdr);
+
 		if (skb_cow_head(skb, 0))
 			goto free_skb;
 
 		tnl_params = (const struct iphdr *)skb->data;
 
-		/* Pull skb since ip_tunnel_xmit() needs skb->data pointing
-		 * to gre header.
-		 */
-		skb_pull(skb, tunnel->hlen + sizeof(struct iphdr));
+		if (!pskb_network_may_pull(skb, pull_len))
+			goto free_skb;
+
+		/* ip_tunnel_xmit() needs skb->data pointing to gre header. */
+		skb_pull(skb, pull_len);
 		skb_reset_mac_header(skb);
 
 		if (skb->ip_summed == CHECKSUM_PARTIAL &&




[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