Skip to content

Commit ad16235

Browse files
q2vengregkh
authored andcommitted
mptcp: Use __sk_dst_get() and dst_dev_rcu() in mptcp_active_enable().
[ Upstream commit 893c49a ] 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: 27069e7 ("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: 833d431 ("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>
1 parent c159590 commit ad16235

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

net/mptcp/ctrl.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,12 +381,15 @@ void mptcp_active_enable(struct sock *sk)
381381
struct mptcp_pernet *pernet = mptcp_get_pernet(sock_net(sk));
382382

383383
if (atomic_read(&pernet->active_disable_times)) {
384-
struct dst_entry *dst = sk_dst_get(sk);
384+
struct net_device *dev;
385+
struct dst_entry *dst;
385386

386-
if (dst && dst->dev && (dst->dev->flags & IFF_LOOPBACK))
387+
rcu_read_lock();
388+
dst = __sk_dst_get(sk);
389+
dev = dst ? dst_dev_rcu(dst) : NULL;
390+
if (dev && (dev->flags & IFF_LOOPBACK))
387391
atomic_set(&pernet->active_disable_times, 0);
388-
389-
dst_release(dst);
392+
rcu_read_unlock();
390393
}
391394
}
392395

0 commit comments

Comments
 (0)