]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mptcp: Use __sk_dst_get() and dst_dev_rcu() in mptcp_active_enable().
authorKuniyuki Iwashima <kuniyu@google.com>
Mon, 20 Oct 2025 15:44:08 +0000 (11:44 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 23 Oct 2025 14:20:46 +0000 (16:20 +0200)
[ Upstream commit 893c49a78d9f85e4b8081b908fb7c407d018106a ]

mptcp_active_enable() is called from subflow_finish_connect(),
which is icsk->icsk_af_ops->sk_rx_dst_set() and it's not always
under RCU.

Using sk_dst_get(sk)->dev could trigger UAF.

Let's use __sk_dst_get() and dst_dev_rcu().

Fixes: 27069e7cb3d1 ("mptcp: disable active MPTCP in case of blackhole")
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20250916214758.650211-8-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Stable-dep-of: 833d4313bc1e ("mptcp: reset blackhole on success with non-loopback ifaces")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/mptcp/ctrl.c

index 6a97d11bda7e2ddfcf5a8931ed5216edcd6a03a9..9e1f61b02a66e6f55eab74d3ba961bdc8b7817ce 100644 (file)
@@ -381,12 +381,15 @@ void mptcp_active_enable(struct sock *sk)
        struct mptcp_pernet *pernet = mptcp_get_pernet(sock_net(sk));
 
        if (atomic_read(&pernet->active_disable_times)) {
-               struct dst_entry *dst = sk_dst_get(sk);
+               struct net_device *dev;
+               struct dst_entry *dst;
 
-               if (dst && dst->dev && (dst->dev->flags & IFF_LOOPBACK))
+               rcu_read_lock();
+               dst = __sk_dst_get(sk);
+               dev = dst ? dst_dev_rcu(dst) : NULL;
+               if (dev && (dev->flags & IFF_LOOPBACK))
                        atomic_set(&pernet->active_disable_times, 0);
-
-               dst_release(dst);
+               rcu_read_unlock();
        }
 }