From: Matthieu Baerts <matttbe@kernel.org>
To: Kuniyuki Iwashima <kuniyu@google.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>,
Kuniyuki Iwashima <kuni1840@gmail.com>,
netdev@vger.kernel.org, Mat Martineau <martineau@kernel.org>,
Geliang Tang <geliang@kernel.org>
Subject: Re: [PATCH v2 net-next 7/7] mptcp: Use __sk_dst_get() and dst_dev_rcu() in mptcp_active_enable().
Date: Wed, 17 Sep 2025 12:17:16 +0200 [thread overview]
Message-ID: <4209a283-8822-47bd-95b7-87e96d9b7ea3@kernel.org> (raw)
In-Reply-To: <20250916214758.650211-8-kuniyu@google.com>
Hi Kuniyuki,
On 16/09/2025 23:47, Kuniyuki Iwashima wrote:
> 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>
Thank you for the fix! It looks good to me!
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
> ---
> Cc: Matthieu Baerts <matttbe@kernel.org>
> Cc: Mat Martineau <martineau@kernel.org>
> Cc: Geliang Tang <geliang@kernel.org>
> ---
> net/mptcp/ctrl.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c
> index c0e516872b4b..e8ffa62ec183 100644
> --- a/net/mptcp/ctrl.c
> +++ b/net/mptcp/ctrl.c
> @@ -501,12 +501,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))
Mmh, I don't know why but the condition was already wrong before your
patch. It should be the opposite: we should reset if we manage to open
an MPTCP connection on a non-loopback interface...
I don't want to block this series for this non-directly related issue.
If you prefer, I can send a fix when this series will be applied. I
guess it would be easier to send it to net-next to avoid conflicts,
which should be fine if we are close to the merge windows.
> + 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();
> }
> }
>
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
next prev parent reply other threads:[~2025-09-17 10:17 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-16 21:47 [PATCH v2 net-next 0/7] net: Fix UAF of sk_dst_get(sk)->dev Kuniyuki Iwashima
2025-09-16 21:47 ` [PATCH v2 net-next 1/7] smc: Fix use-after-free in __pnet_find_base_ndev() Kuniyuki Iwashima
2025-09-17 6:52 ` Mahanta Jambigi
2025-09-17 6:56 ` Kuniyuki Iwashima
2025-09-17 14:18 ` Eric Dumazet
2025-09-16 21:47 ` [PATCH v2 net-next 2/7] smc: Use __sk_dst_get() and dst_dev_rcu() in in smc_clc_prfx_set() Kuniyuki Iwashima
2025-09-17 14:12 ` Eric Dumazet
2025-09-16 21:47 ` [PATCH v2 net-next 3/7] smc: Use __sk_dst_get() and dst_dev_rcu() in smc_clc_prfx_match() Kuniyuki Iwashima
2025-09-17 14:13 ` Eric Dumazet
2025-09-16 21:47 ` [PATCH v2 net-next 4/7] smc: Use __sk_dst_get() and dst_dev_rcu() in smc_vlan_by_tcpsk() Kuniyuki Iwashima
2025-09-17 9:13 ` Mahanta Jambigi
2025-09-17 14:09 ` Eric Dumazet
2025-09-17 17:41 ` Kuniyuki Iwashima
2025-09-18 7:34 ` Mahanta Jambigi
2025-09-16 21:47 ` [PATCH v2 net-next 5/7] tls: Use __sk_dst_get() and dst_dev_rcu() in get_netdev_for_sock() Kuniyuki Iwashima
2025-09-17 14:14 ` Eric Dumazet
2025-09-17 15:45 ` Sabrina Dubroca
2025-09-16 21:47 ` [PATCH v2 net-next 6/7] mptcp: Call dst_release() in mptcp_active_enable() Kuniyuki Iwashima
2025-09-17 10:17 ` Matthieu Baerts
2025-09-17 14:04 ` Eric Dumazet
2025-09-17 14:51 ` Matthieu Baerts
2025-09-16 21:47 ` [PATCH v2 net-next 7/7] mptcp: Use __sk_dst_get() and dst_dev_rcu() " Kuniyuki Iwashima
2025-09-17 10:17 ` Matthieu Baerts [this message]
2025-09-17 17:43 ` Kuniyuki Iwashima
2025-09-17 14:10 ` Eric Dumazet
2025-09-18 1:20 ` [PATCH v2 net-next 0/7] net: Fix UAF of sk_dst_get(sk)->dev patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4209a283-8822-47bd-95b7-87e96d9b7ea3@kernel.org \
--to=matttbe@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=geliang@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=kuniyu@google.com \
--cc=martineau@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).