FAILED: patch "[PATCH] mptcp: fix duplicate subflow creation" failed to apply to 5.15-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 045e9d812868a2d80b7a57b224ce8009444b7bbc
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2024022602-extended-buffer-5cf7@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^..
Possible dependencies:
045e9d812868 ("mptcp: fix duplicate subflow creation") b9d69db87fb7 ("mptcp: let the in-kernel PM use mixed IPv4 and IPv6 addresses") bedee0b56113 ("mptcp: address lookup improvements")4638de5aefe5 ("mptcp: handle local addrs announced by userspace PMs") c682bf536cf4 ("mptcp: add pm_nl_pernet helpers")4cf86ae84c71 ("mptcp: strict local address ID selection") d045b9eb95a9 ("mptcp: introduce implicit endpoints")aaa25a2fa796 ("Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 045e9d812868a2d80b7a57b224ce8009444b7bbc Mon Sep 17 00:00:00 2001
From: Paolo Abeni <[email protected]>
Date: Thu, 15 Feb 2024 19:25:33 +0100
Subject: [PATCH] mptcp: fix duplicate subflow creation
Fullmesh endpoints could end-up unexpectedly generating duplicate subflows - same local and remote addresses - when multiple incoming ADD_ADDR are processed before the PM creates the subflow for the local endpoints.
Address the issue explicitly checking for duplicates at subflow creation time.
To avoid a quadratic computational complexity, track the unavailable remote address ids in a temporary bitmap and initialize such bitmap with the remote ids of all the existing subflows matching the local address currently processed.
The above allows additionally replacing the existing code checking for duplicate entry in the current set with a simple bit test operation.
net/mptcp/pm_netlink.c +18 -15
@@ -396,19 +396,6 @@ void mptcp_pm_free_anno_list(struct mptcp_sock *msk) } } -static bool lookup_address_in_vec (const struct mptcp_addr_info *addrs,unsigned int nr, -const struct mptcp_addr_info *addr) -{ -int i; - -for (i =0 ; i < nr; i++) { -if (addrs[i].id == addr->id) -return true; - } - -return false; -} -/* Fill all the remote addresses into the array addrs[], * and return the array size. */
@@ -440,6 +427,16 @@ static unsigned int fill_remote_addresses_vec(struct mptcp_sock *msk, msk->pm.subflows++; addrs[i++] = remote; }else { +DECLARE_BITMAP (unavail_id,MPTCP_PM_MAX_ADDR_ID +1 ); + +/* Forbid creation of new subflows matching existing +* ones, possibly already created by incoming ADD_ADDR +*/ +bitmap_zero (unavail_id,MPTCP_PM_MAX_ADDR_ID +1 ); +mptcp_for_each_subflow (msk, subflow) +if (READ_ONCE (subflow->local_id) == local->id) +__set_bit (subflow->remote_id, unavail_id); +mptcp_for_each_subflow (msk, subflow) { ssk =mptcp_subflow_tcp_sock (subflow);remote_address ((struct sock_common *)ssk, &addrs[i]);
@@ -447,11 +444,17 @@ static unsigned int fill_remote_addresses_vec(struct mptcp_sock *msk,if (deny_id0 && !addrs[i].id)continue ; +if (test_bit (addrs[i].id, unavail_id)) +continue ; +if (!mptcp_pm_addr_families_match (sk, local, &addrs[i]))continue ; -if (!lookup_address_in_vec (addrs, i, &addrs[i]) && - msk->pm.subflows < subflows_max) { +if (msk->pm.subflows < subflows_max) { +/* forbid creating multiple address towards +* this id +*/ +__set_bit (addrs[i].id, unavail_id); msk->pm.subflows++; i++; }
Matthieu Baerts
maintainerHi Greg,
Quoted 2 lines · On 26/02/2024 14:18, [email protected] wrote:
The patch below does not apply to the 5.15-stable tree.
(...)
Quoted 10 lines
Possible dependencies:
045e9d812868("mptcp: fix duplicate subflow creation")b9d69db87fb7("mptcp: let the in-kernel PM use mixed IPv4 and IPv6 addresses")bedee0b56113("mptcp: address lookup improvements")4638de5aefe5("mptcp: handle local addrs announced by userspace PMs")c682bf536cf4("mptcp: addpm_nl_pernethelpers")4cf86ae84c71("mptcp: strict local address ID selection")d045b9eb95a9("mptcp: introduce implicit endpoints")aaa25a2fa796("Mergegit://git.kernel.org/pub/scm/linux/kernel/git/netdev/net")
(...)
Quoted 13 lines
From
045e9d812868a2d80b7a57b224ce8009444b7bbcMon Sep 17 00:00:00 2001
From: Paolo Abeni <[email protected]>
Date: Thu, 15 Feb 2024 19:25:33 +0100
Subject: [PATCH] mptcp: fix duplicate subflow creationFullmesh endpoints could end-up unexpectedly generating duplicate subflows - same local and remote addresses - when multiple incoming
ADD_ADDRare processed before the PM creates the subflow for the local endpoints.Address the issue explicitly checking for duplicates at subflow creation time.
Quoted 8 lines
To avoid a quadratic computational complexity, track the unavailable remote address ids in a temporary bitmap and initialize such bitmap with the remote ids of all the existing subflows matching the local address currently processed.
The above allows additionally replacing the existing code checking for duplicate entry in the current set with a simple bit test operation.
FYI, because of the various conflicts, and because the issue is quite harmless -- duplicated subflows are created, but only when trying to create a high number of subflows, limited to 8 in v5.15, almost unnoticed bug so far --, I think it is better not to try to backport this patch to v5.15.
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.