All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH mptcp-net] mptcp: pm: kernel: c-flag: mark as used only when it is
@ 2026-10-22  9:14 Matthieu Baerts (NGI0)
  2026-10-22  9:24 ` sashiko-bot
  2026-10-22 10:26 ` MPTCP CI
  0 siblings, 2 replies; 4+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-10-22  9:14 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Yiming Qian, Matthieu Baerts (NGI0)

The ID was marked as used before checking if it could actually be used
in all conditions: if the families match and the local endpoint is not
the one linked to the initial endpoint.

Marking endpoints as used while they are not can have an impact on the
local_addr_used counter when endpoints are removed -- CAP_NET_ADMIN is
required -- and active connections have such badly marked endpoints. In
this case, the local counter will be decremented while it shouldn't. If
the counter was already at 0, this warning will be emitted:

  WARNING: net/mptcp/pm_kernel.c:1080 at __mark_subflow_endp_available+0x46/0x50, CPU#0: a.out/149
  RIP: 0010:__mark_subflow_endp_available (net/mptcp/pm_kernel.c:1080 (discriminator 2) net/mptcp/pm_kernel.c:1076 (discriminator 2))
  Call Trace:
   mptcp_pm_nl_del_addr_doit (net/mptcp/pm_kernel.c:1112 net/mptcp/pm_kernel.c:1227)
   genl_family_rcv_msg_doit (net/netlink/genetlink.c:1114)

The fix is easy: simply moving the '__clear_bit' instruction after the
two checks that would cause the endpoint not to be used.

Fixes: 4b1ff850e0c1 ("mptcp: pm: in-kernel: usable client side with C-flag")
Reported-by: Yiming Qian <yimingqian591@gmail.com>
Closes: https://lore.kernel.org/20261006114409.117190-1-yimingqian591@gmail.com
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
Note: this patch supersedes the patch mentioned above: the author
doesn't seem to be willing to send a v2. Because security@k.o was Cc'ed
on public ML, that's forcing us not to wait, even if this fix is just
about a counter that will be wrongly decremented when MPTCP endpoints
are removed (requiring CAP_NET_ADMIN). Put the original author as
"Reported-by" following the recommendations given to maintainers in such
cases.
---
 net/mptcp/pm_kernel.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c
index d3014bf57bf3..3e473a81389d 100644
--- a/net/mptcp/pm_kernel.c
+++ b/net/mptcp/pm_kernel.c
@@ -582,14 +582,14 @@ fill_local_addresses_vec_c_flag(struct mptcp_sock *msk,
 		if (!select_local_address(pernet, msk, local))
 			break;
 
-		__clear_bit(local->addr.id, msk->pm.id_avail_bitmap);
-
 		if (!mptcp_pm_addr_families_match(sk, &local->addr, remote))
 			continue;
 
 		if (local->addr.id == msk->mpc_endpoint_id)
 			continue;
 
+		__clear_bit(local->addr.id, msk->pm.id_avail_bitmap);
+
 		msk->pm.local_addr_used++;
 		msk->pm.extra_subflows++;
 		i++;

---
base-commit: 1c36f79c9bd761bc3a41d246d7a4242b287d2fc7
change-id: 20261006-mptcp-pm-cflag-clear-when-used-ee817b26a553

Best regards,
--  
Matthieu Baerts (NGI0) <matttbe@kernel.org>


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-10-22 10:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-22  9:14 [PATCH mptcp-net] mptcp: pm: kernel: c-flag: mark as used only when it is Matthieu Baerts (NGI0)
2026-10-22  9:24 ` sashiko-bot
2026-10-22 10:12   ` Matthieu Baerts
2026-10-22 10:26 ` MPTCP CI

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.