Merge branch 'mptcp-misc-fixes-for-v7-2-rc5'

Matthieu Baerts says:

====================
mptcp: misc fixes for v7.2-rc5

Here are various unrelated fixes:

- Patch 1: decrement extra subflows counter in case of errors with
  passive MP_JOIN. A fix for v5.7.

- Patch 2: fix use-after-free in userspace_pm_get_local_id. A fix for
  v5.19.

- Patch 3: fix stale skb->sk reference on subflow close, in case of
  concurrent read operation. A fix for v6.19.

- Patch 4: wait on the correct port in the userspace_pm.sh selftest. A
  fix for v6.19.

- Patch 5: fix a BUILD_BUG_ON on legacy ARM config. A fix for v7.1.
====================

Link: https://patch.msgid.link/20260722-net-mptcp-misc-fixes-7-2-rc5-v1-0-6fb595bc86ef@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Jakub Kicinski 2026-07-23 10:50:42 -07:00
commit 1d4da823b7
4 changed files with 27 additions and 21 deletions

View File

@ -571,10 +571,7 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,
bool ret = false;
/* Zero `use_ack` and `use_map` flags with one shot. */
BUILD_BUG_ON(sizeof_field(struct mptcp_ext, flags) != sizeof(u16));
BUILD_BUG_ON(!IS_ALIGNED(offsetof(struct mptcp_ext, flags),
sizeof(u16)));
*(u16 *)&opts->ext_copy.flags = 0;
memset(&opts->ext_copy.flags, 0, sizeof(opts->ext_copy.flags));
opts->csum_reqd = READ_ONCE(msk->csum_enabled);
mpext = skb ? mptcp_get_ext(skb) : NULL;

View File

@ -132,12 +132,15 @@ int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk,
__be16 msk_sport = ((struct inet_sock *)
inet_sk((struct sock *)msk))->inet_sport;
struct mptcp_pm_addr_entry *entry;
int id;
spin_lock_bh(&msk->pm.lock);
entry = mptcp_userspace_pm_lookup_addr(msk, &skc->addr);
id = entry ? entry->addr.id : -1;
spin_unlock_bh(&msk->pm.lock);
if (entry)
return entry->addr.id;
if (id != -1)
return id;
if (skc->addr.port == msk_sport)
skc->addr.port = 0;

View File

@ -2545,6 +2545,22 @@ static void __mptcp_subflow_disconnect(struct sock *ssk,
}
}
static void mptcp_cleanup_ssk_backlog(struct sock *sk, struct sock *ssk)
{
struct mptcp_sock *msk = mptcp_sk(sk);
struct sk_buff *skb;
mptcp_data_lock(sk);
list_for_each_entry(skb, &msk->backlog_list, list) {
if (skb->sk != ssk)
continue;
atomic_sub(skb->truesize, &skb->sk->sk_rmem_alloc);
skb->sk = NULL;
}
mptcp_data_unlock(sk);
}
/* subflow sockets can be either outgoing (connect) or incoming
* (accept).
*
@ -2568,6 +2584,9 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
lock_sock_nested(ssk, SINGLE_DEPTH_NESTING);
subflow->closing = 1;
if (flags & MPTCP_CF_PUSH)
mptcp_cleanup_ssk_backlog(sk, ssk);
/* Borrow the fwd allocated page left-over; fwd memory for the subflow
* could be negative at this point, but will be reach zero soon - when
* the data allocated using such fragment will be freed.
@ -2659,9 +2678,6 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
void mptcp_close_ssk(struct sock *sk, struct sock *ssk,
struct mptcp_subflow_context *subflow)
{
struct mptcp_sock *msk = mptcp_sk(sk);
struct sk_buff *skb;
/* The first subflow can already be closed or disconnected */
if (subflow->close_event_done || READ_ONCE(subflow->local_id) < 0)
return;
@ -2671,17 +2687,6 @@ void mptcp_close_ssk(struct sock *sk, struct sock *ssk,
if (sk->sk_state == TCP_ESTABLISHED)
mptcp_event(MPTCP_EVENT_SUB_CLOSED, mptcp_sk(sk), ssk, GFP_KERNEL);
/* Remove any reference from the backlog to this ssk; backlog skbs consume
* space in the msk receive queue, no need to touch sk->sk_rmem_alloc
*/
list_for_each_entry(skb, &msk->backlog_list, list) {
if (skb->sk != ssk)
continue;
atomic_sub(skb->truesize, &skb->sk->sk_rmem_alloc);
skb->sk = NULL;
}
/* subflow aborted before reaching the fully_established status
* attempt the creation of the next subflow
*/
@ -3907,6 +3912,7 @@ bool mptcp_finish_join(struct sock *ssk)
mptcp_data_unlock(parent);
if (!ret) {
mptcp_pm_close_subflow(msk);
err_prohibited:
subflow->reset_reason = MPTCP_RST_EPROHIBIT;
return false;

View File

@ -212,7 +212,7 @@ make_connection()
./mptcp_connect -s MPTCP -w 300 -p $app_port -l $listen_addr > /dev/null 2>&1 &
local server_pid=$!
mptcp_lib_wait_local_port_listen "${ns1}" "${port}"
mptcp_lib_wait_local_port_listen "${ns1}" "${app_port}"
# Run the client, transfer $file and stay connected to the server
# to conduct tests