mirror of
https://github.com/torvalds/linux.git
synced 2025-11-05 11:10:22 +02:00
mptcp: Use __sk_dst_get() and dst_dev_rcu() in mptcp_active_enable().
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: 27069e7cb3 ("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>
This commit is contained in:
parent
108a86c71c
commit
893c49a78d
1 changed files with 7 additions and 4 deletions
|
|
@ -501,12 +501,15 @@ void mptcp_active_enable(struct sock *sk)
|
||||||
struct mptcp_pernet *pernet = mptcp_get_pernet(sock_net(sk));
|
struct mptcp_pernet *pernet = mptcp_get_pernet(sock_net(sk));
|
||||||
|
|
||||||
if (atomic_read(&pernet->active_disable_times)) {
|
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);
|
atomic_set(&pernet->active_disable_times, 0);
|
||||||
|
rcu_read_unlock();
|
||||||
dst_release(dst);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue