MPTCP Linux Development
 help / color / mirror / Atom feed
* [PATCH mptcp-net v2] mptcp: pm: kernel: c-flag: mark as used only when it is
@ 2026-10-22 10:49 Matthieu Baerts (NGI0)
  2026-10-22 12:33 ` MPTCP CI
  2026-10-23 23:45 ` netdev-bot+sashiko
  0 siblings, 2 replies; 3+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-10-22 10:49 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: increment local_addr_used similar to what is done in
mptcp_pm_create_subflow_or_signal_addr() for the non C-flag case.

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>
---
Changes in v2:
- Move the increment of local_addr_used before checking the family,
  similar to what is done for the non C-flag case.
- Link to v1: https://patch.msgid.link/20261022-mptcp-pm-cflag-clear-when-used-v1-1-516c09b4ee65@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 | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c
index d3014bf57bf3..fb611c4b3eb8 100644
--- a/net/mptcp/pm_kernel.c
+++ b/net/mptcp/pm_kernel.c
@@ -584,13 +584,15 @@ fill_local_addresses_vec_c_flag(struct mptcp_sock *msk,
 
 		__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;
 
+		/* Increment before checking families, similar to non C-flag */
 		msk->pm.local_addr_used++;
+
+		if (!mptcp_pm_addr_families_match(sk, &local->addr, remote))
+			continue;
+
 		msk->pm.extra_subflows++;
 		i++;
 

---
base-commit: 894c5749a6139dffd3687f165fb7119f9e572ed3
change-id: 20261006-mptcp-pm-cflag-clear-when-used-ee817b26a553

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


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

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

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox