All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>,
	"MPTCP Linux" <mptcp@lists.linux.dev>
Subject: Re: [PATCH mptcp-net] mptcp: pm: kernel: c-flag: mark as used only when it is
Date: Thu, 22 Oct 2026 09:24:02 +0000	[thread overview]
Message-ID: <sashiko-outbox-181256@kernel.org> (raw)
In-Reply-To: <20261022-mptcp-pm-cflag-clear-when-used-v1-1-516c09b4ee65@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] mptcp: infinite loop in fill_local_addresses_vec_c_flag() on skipped endpoint
--

commit 13a1b915ae070fcc7bed06cf022912abbebad663
Author: Matthieu Baerts (NGI0) <matttbe@kernel.org>

mptcp: pm: kernel: c-flag: mark as used only when it is

This commit moves the clearing of local->addr.id in msk->pm.id_avail_bitmap
in fill_local_addresses_vec_c_flag() until after checking that the address
families match and the local endpoint is not msk->mpc_endpoint_id.

> diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c
> index d3014bf57bf3c..3e473a81389d3 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);

[Severity: Critical]
Could moving __clear_bit() after the continue statements cause an infinite
loop in fill_local_addresses_vec_c_flag()?

In net/mptcp/pm_kernel.c, select_local_address() always scans
pernet->endp_list from the head and returns the first subflow endpoint whose
ID is still set in msk->pm.id_avail_bitmap:

net/mptcp/pm_kernel.c:select_local_address() {
	...
	list_for_each_entry_rcu(entry, &pernet->endp_list, list) {
		if (!(entry->flags & MPTCP_PM_ADDR_FLAG_SUBFLOW))
			continue;

		if (!test_bit(entry->addr.id, msk->pm.id_avail_bitmap))
			continue;

		new_local->addr = entry->addr;
		new_local->flags = entry->flags;
		new_local->ifindex = entry->ifindex;
		found = true;
		break;
	}
	...
}

When __mptcp_pm_kernel_worker() -> mptcp_pm_nl_add_addr_received() ->
fill_local_addresses_vec() -> fill_local_addresses_vec_c_flag() runs and the
selected endpoint either fails mptcp_pm_addr_families_match() or matches
msk->mpc_endpoint_id, the loop takes a continue branch without clearing
local->addr.id in msk->pm.id_avail_bitmap or incrementing
msk->pm.local_addr_used.

On the next iteration of while (msk->pm.local_addr_used < endp_subflow_max),
wouldn't select_local_address() return the exact same endpoint again and loop
indefinitely?

> +
>  		msk->pm.local_addr_used++;
>  		msk->pm.extra_subflows++;
>  		i++;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261022-mptcp-pm-cflag-clear-when-used-v1-1-516c09b4ee65@kernel.org?part=1

  reply	other threads:[~2026-10-22  9:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2026-10-22 10:12   ` Matthieu Baerts
2026-10-22 10:26 ` MPTCP CI

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=sashiko-outbox-181256@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=matttbe@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 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.