Patch "pptp: Fix fib lookup calls." 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

    pptp: Fix fib lookup calls.

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:
     pptp-fix-fib-lookup-calls.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 1b82f8063aceae2163cf6b762c67068e8ba9b803
Author: Guillaume Nault <gnault@xxxxxxxxxx>
Date:   Mon Jul 3 19:14:46 2023 +0200

    pptp: Fix fib lookup calls.
    
    [ Upstream commit 84bef5b6037c15180ef88ac4216dc621d16df1a6 ]
    
    PPTP uses pppox sockets (struct pppox_sock). These sockets don't embed
    an inet_sock structure, so it's invalid to call inet_sk() on them.
    
    Therefore, the ip_route_output_ports() call in pptp_connect() has two
    problems:
    
      * The tos variable is set with RT_CONN_FLAGS(sk), which calls
        inet_sk() on the pppox socket.
    
      * ip_route_output_ports() tries to retrieve routing flags using
        inet_sk_flowi_flags(), which is also going to call inet_sk() on the
        pppox socket.
    
    While PPTP doesn't use inet sockets, it's actually really layered on
    top of IP and therefore needs a proper way to do fib lookups. So let's
    define pptp_route_output() to get a struct rtable from a pptp socket.
    Let's also replace the ip_route_output_ports() call of pptp_xmit() for
    consistency.
    
    In practice, this means that:
    
      * pptp_connect() sets ->flowi4_tos and ->flowi4_flags to zero instead
        of using bits of unrelated struct pppox_sock fields.
    
      * pptp_xmit() now respects ->sk_mark and ->sk_uid.
    
      * pptp_xmit() now calls the security_sk_classify_flow() security
        hook, thus allowing to set ->flowic_secid.
    
      * pptp_xmit() now passes the pppox socket to xfrm_lookup_route().
    
    Found by code inspection.
    
    Fixes: 00959ade36ac ("PPTP: PPP over IPv4 (Point-to-Point Tunneling Protocol)")
    Signed-off-by: Guillaume Nault <gnault@xxxxxxxxxx>
    Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c
index ee5058445d06e..05a75b5a8b680 100644
--- a/drivers/net/ppp/pptp.c
+++ b/drivers/net/ppp/pptp.c
@@ -24,6 +24,7 @@
 #include <linux/in.h>
 #include <linux/ip.h>
 #include <linux/rcupdate.h>
+#include <linux/security.h>
 #include <linux/spinlock.h>
 
 #include <net/sock.h>
@@ -128,6 +129,23 @@ static void del_chan(struct pppox_sock *sock)
 	spin_unlock(&chan_lock);
 }
 
+static struct rtable *pptp_route_output(struct pppox_sock *po,
+					struct flowi4 *fl4)
+{
+	struct sock *sk = &po->sk;
+	struct net *net;
+
+	net = sock_net(sk);
+	flowi4_init_output(fl4, sk->sk_bound_dev_if, sk->sk_mark, 0,
+			   RT_SCOPE_UNIVERSE, IPPROTO_GRE, 0,
+			   po->proto.pptp.dst_addr.sin_addr.s_addr,
+			   po->proto.pptp.src_addr.sin_addr.s_addr,
+			   0, 0, sock_net_uid(net, sk));
+	security_sk_classify_flow(sk, flowi4_to_flowi_common(fl4));
+
+	return ip_route_output_flow(net, fl4, sk);
+}
+
 static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
 {
 	struct sock *sk = (struct sock *) chan->private;
@@ -151,11 +169,7 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
 	if (sk_pppox(po)->sk_state & PPPOX_DEAD)
 		goto tx_error;
 
-	rt = ip_route_output_ports(net, &fl4, NULL,
-				   opt->dst_addr.sin_addr.s_addr,
-				   opt->src_addr.sin_addr.s_addr,
-				   0, 0, IPPROTO_GRE,
-				   RT_TOS(0), sk->sk_bound_dev_if);
+	rt = pptp_route_output(po, &fl4);
 	if (IS_ERR(rt))
 		goto tx_error;
 
@@ -440,12 +454,7 @@ static int pptp_connect(struct socket *sock, struct sockaddr *uservaddr,
 	po->chan.private = sk;
 	po->chan.ops = &pptp_chan_ops;
 
-	rt = ip_route_output_ports(sock_net(sk), &fl4, sk,
-				   opt->dst_addr.sin_addr.s_addr,
-				   opt->src_addr.sin_addr.s_addr,
-				   0, 0,
-				   IPPROTO_GRE, RT_CONN_FLAGS(sk),
-				   sk->sk_bound_dev_if);
+	rt = pptp_route_output(po, &fl4);
 	if (IS_ERR(rt)) {
 		error = -EHOSTUNREACH;
 		goto end;



[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