mptcp: fix duplicate subflow creation
Subsystems (4)
Paolo Abeni
maintainerv2 cover mptcp: fix duplicate subflow creation
As reported by Mat, the in kernel PM can, in some edge scenarios, unexpectedly create multiple subflows with the same local and remote address.
The real fix is implemented by patch 4/4 with some more accurate check at subflow creation time.
Patches 1-3 are roughly optional pre-requisities, added to avoid introducing more data-races with the actual fix. Patch 1/4 is a bit debatable, as it changes the existing ULP API, but I could not find a better solution and there is some similar prior art:
commit 0df48c26d841 ("tcp: add tcpi_bytes_acked to tcp_info")
This address feedback from Mat on v1, see the patches changelog for the details (no changes in patch 1/4).
Paolo Abeni (4):
mptcp: fix lockless access in subflow ULP diag
mptcp: fix data races on local_id
mptcp: fix data races on remote_id
mptcp: fix duplicate subflow creation
include/net/tcp.h | 2 +- net/mptcp/diag.c | 8 +++++-- net/mptcp/pm_netlink.c | 45 +++++++++++++++++++++------------------- net/mptcp/pm_userspace.c | 2 +- net/mptcp/protocol.c | 2 +- net/mptcp/protocol.h | 15 +++++++++++--- net/mptcp/subflow.c | 15 +++++++------- net/tls/tls_main.c | 2 +- 8 files changed, 54 insertions(+), 37 deletions(-)
Signature · 1 line
2.43.0
Paolo Abeni
maintainerPATCH v2 1/4 mptcp: fix lockless access in subflow ULP diag
Since the introduction of the subflow ULP diag interface, the dump callback accessed all the subflow data with lockless.
We need either to annotate all the read and write operation accordingly, or acquire the subflow socket lock. Let's do latter, even if slower, to avoid a diffstat havoc.
---
note: tls ulp diag has likely the same issue.
--- include/net/tcp.h | 2 +- net/mptcp/diag.c | 6 +++++- net/tls/tls_main.c | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-)
include/net/tcp.h +1 -1
@@ -2551,7 +2551,7 @@ struct tcp_ulp_ops {/* cleanup ulp */ void (*release)(struct sock *sk);/* diagnostic */ -int (*get_info)(const struct sock *sk,struct sk_buff *skb); +int (*get_info)(struct sock *sk,struct sk_buff *skb);size_t (*get_info_size)(const struct sock *sk);/* clone ulp */ void (*clone)(const struct request_sock *req, struct sock *newsk,
net/mptcp/diag.c +5 -1
@@ -13,17 +13,19 @@#include <uapi/linux/mptcp.h> #include "protocol.h" -static int subflow_get_info (const struct sock *sk,struct sk_buff *skb) +static int subflow_get_info (struct sock *sk,struct sk_buff *skb) {struct mptcp_subflow_context *sf;struct nlattr *start;u32 flags =0 ; +bool slow;int err; start =nla_nest_start_noflag (skb,INET_ULP_INFO_MPTCP );if (!start)return -EMSGSIZE ; + slow =lock_sock_fast (sk);rcu_read_lock (); sf =rcu_dereference (inet_csk (sk)->icsk_ulp_data);if (!sf) {
@@ -69,11 +71,13 @@ static int subflow_get_info(const struct sock *sk, struct sk_buff *skb) }rcu_read_unlock (); +unlock_sock_fast (sk, slow);nla_nest_end (skb, start);return 0 ; nla_failure:rcu_read_unlock (); +unlock_sock_fast (sk, slow);nla_nest_cancel (skb, start);return err; }
net/tls/tls_main.c +1 -1
@@ -1003,7 +1003,7 @@ static u16 tls_user_config(struct tls_context *ctx, bool tx)return 0 ; } -static int tls_get_info (const struct sock *sk,struct sk_buff *skb) +static int tls_get_info (struct sock *sk,struct sk_buff *skb) {u16 version, cipher_type;struct tls_context *ctx;
Signature · 1 line
2.43.0
Paolo Abeni
maintainerPATCH v2 2/4 mptcp: fix data races on local_id
In reply to Paolo AbeniThe local address id is accessed lockless by the NL PM, add all the required ONCE annotation. There is a caveat: the local id can be initialized late in the subflow life-cycle, and its validity is controlled by the local_id_valid flag.
Remove such flag and encode the validity in the local_id field itself with negative value before initialization. That allows accessing the field consistently with a single read operation.
---
v1 -> v2:
- get_local_id() return u8
- use extend helper usage in more places
- READ_ONCE() in pm_userspace
--- net/mptcp/diag.c | 2 +- net/mptcp/pm_netlink.c | 6 +++--- net/mptcp/pm_userspace.c | 2 +- net/mptcp/protocol.c | 2 +- net/mptcp/protocol.h | 15 ++++++++++++--- net/mptcp/subflow.c | 9 +++++---- 6 files changed, 23 insertions(+), 13 deletions(-)
net/mptcp/diag.c +1 -1
@@ -65,7 +65,7 @@ static int subflow_get_info(struct sock *sk, struct sk_buff *skb) sf->map_data_len) || nla_put_u32(skb, MPTCP_SUBFLOW_ATTR_FLAGS, flags) || nla_put_u8(skb, MPTCP_SUBFLOW_ATTR_ID_REM, sf->remote_id) || - nla_put_u8(skb, MPTCP_SUBFLOW_ATTR_ID_LOC, sf->local_id)) { + nla_put_u8(skb, MPTCP_SUBFLOW_ATTR_ID_LOC, subflow_get_local_id(sf))) { err = -EMSGSIZE ; goto nla_failure; }
net/mptcp/pm_netlink.c +3 -3
@@ -800,7 +800,7 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk,mptcp_for_each_subflow_safe (msk, subflow, tmp) {struct sock *ssk =mptcp_subflow_tcp_sock (subflow);int how =RCV_SHUTDOWN |SEND_SHUTDOWN ; -u8 id = subflow->local_id; +u8 id =subflow_get_local_id (subflow);if (rm_type ==MPTCP_MIB_RMADDR && subflow->remote_id != rm_id)continue ;
@@ -809,7 +809,7 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk,pr_debug (" -> %s rm_list_ids[%d]=%u local_id=%u remote_id=%u mpc_id=%u" , rm_type ==MPTCP_MIB_RMADDR ?"address" :"subflow" , - i, rm_id, subflow->local_id, subflow->remote_id, + i, rm_id, id, subflow->remote_id, msk->mpc_endpoint_id);spin_unlock_bh (&msk->pm.lock);mptcp_subflow_shutdown (sk, ssk, how);
@@ -1980,7 +1980,7 @@ static int mptcp_event_add_subflow(struct sk_buff *skb, const struct sock *ssk)if (WARN_ON_ONCE (!sf))return -EINVAL ; -if (nla_put_u8 (skb,MPTCP_ATTR_LOC_ID , sf->local_id)) +if (nla_put_u8 (skb,MPTCP_ATTR_LOC_ID ,subflow_get_local_id (sf)))return -EMSGSIZE ;if (nla_put_u8 (skb,MPTCP_ATTR_REM_ID , sf->remote_id))
net/mptcp/pm_userspace.c +1 -1
@@ -233,7 +233,7 @@ static int mptcp_userspace_pm_remove_id_zero_address(struct mptcp_sock *msk,lock_sock (sk);mptcp_for_each_subflow (msk, subflow) { -if (subflow->local_id ==0 ) { +if (READ_ONCE (subflow->local_id) ==0 ) { has_id_0 = true;break ; }
net/mptcp/protocol.c +1 -1
@@ -85,7 +85,7 @@ static int __mptcp_socket_create(struct mptcp_sock *msk) subflow->subflow_id = msk->subflow_id++;/* This is the first subflow, always with id 0 */ - subflow->local_id_valid =1 ; +WRITE_ONCE (subflow->local_id,0 );mptcp_sock_graft (msk->first, sk->sk_socket);iput (SOCK_INODE (ssock));
net/mptcp/protocol.h +12 -3
@@ -493,10 +493,9 @@ struct mptcp_subflow_context { remote_key_valid : 1, /* received the peer key from */ disposable : 1, /* ctx can be free at ulp release time */ stale : 1, /* unable to snd/rcv data, do not use for xmit */ - local_id_valid : 1, /* local_id is correctly initialized */ valid_csum_seen : 1, /* at least one csum validated */ is_mptfo : 1, /* subflow is doing TFO */ - __unused : 9; + __unused : 10;bool data_avail;bool scheduled;u32 remote_nonce;
@@ -507,7 +506,7 @@ struct mptcp_subflow_context {u8 hmac[MPTCPOPT_HMAC_LEN ];/* MPJ subflow only */ u64 iasn;/* initial ack sequence number, MPC subflows only */ }; -u8 local_id; +s16 local_id;/* if negative not initialized yet */ u8 remote_id; u8 reset_seen:1; u8 reset_transient:1;
@@ -558,6 +557,7 @@ mptcp_subflow_ctx_reset(struct mptcp_subflow_context *subflow) {memset (&subflow->reset,0 ,sizeof (subflow->reset)); subflow->request_mptcp =1 ; +WRITE_ONCE (subflow->local_id,-1 ); } static inline u64
@@ -1064,6 +1064,15 @@ int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc);int mptcp_pm_nl_get_local_id (struct mptcp_sock *msk,struct mptcp_addr_info *skc);int mptcp_userspace_pm_get_local_id (struct mptcp_sock *msk,struct mptcp_addr_info *skc); +static inline u8 subflow_get_local_id (const struct mptcp_subflow_context *subflow) +{ +int local_id =READ_ONCE (subflow->local_id); + +if (local_id <0 ) +return 0 ; +return local_id; +} +void __init mptcp_pm_nl_init (void );void mptcp_pm_nl_work (struct mptcp_sock *msk); void mptcp_pm_nl_rm_subflow_received(struct mptcp_sock *msk,
net/mptcp/subflow.c +5 -4
@@ -578,8 +578,8 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb)static void subflow_set_local_id (struct mptcp_subflow_context *subflow,int local_id) { - subflow->local_id = local_id; - subflow->local_id_valid =1 ; +WARN_ON_ONCE (local_id <0 || local_id >255 ); +WRITE_ONCE (subflow->local_id, local_id); }static int subflow_chk_local_id (struct sock *sk)
@@ -588,7 +588,7 @@ static int subflow_chk_local_id(struct sock *sk)struct mptcp_sock *msk =mptcp_sk (subflow->conn);int err; -if (likely (subflow->local_id_valid)) +if (likely (subflow->local_id >=0 ))return 0 ; err =mptcp_pm_get_local_id (msk, (struct sock_common *)sk);
@@ -1733,6 +1733,7 @@ static struct mptcp_subflow_context *subflow_create_ctx(struct sock *sk,pr_debug ("subflow=%p" , ctx); ctx->tcp_sock = sk; +WRITE_ONCE (ctx->local_id,-1 );return ctx; }
@@ -1968,7 +1969,7 @@ static void subflow_ulp_clone(const struct request_sock *req, new_ctx->idsn = subflow_req->idsn;/* this is the first subflow, id is always 0 */ - new_ctx->local_id_valid =1 ; +subflow_set_local_id (new_ctx,0 ); }else if (subflow_req->mp_join) { new_ctx->ssn_offset = subflow_req->ssn_offset; new_ctx->mp_join =1 ;
Signature · 1 line
2.43.0
Paolo Abeni
maintainerPATCH v2 3/4 mptcp: fix data races on remote_id
In reply to Paolo AbeniSimilar to the previous patch, address the data race on remote_id, adding the suitable ONCE annotations.
---
v1 -> v2:
- srm_id -> remote_id
--- net/mptcp/pm_netlink.c | 8 ++++---- net/mptcp/subflow.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-)
net/mptcp/pm_netlink.c +4 -4
@@ -443,7 +443,7 @@ static unsigned int fill_remote_addresses_vec(struct mptcp_sock *msk,mptcp_for_each_subflow (msk, subflow) { ssk =mptcp_subflow_tcp_sock (subflow);remote_address ((struct sock_common *)ssk, &addrs[i]); - addrs[i].id = subflow->remote_id; + addrs[i].id =READ_ONCE (subflow->remote_id);if (deny_id0 && !addrs[i].id)continue ;
@@ -799,18 +799,18 @@ static void mptcp_pm_nl_rm_addr_or_subflow(struct mptcp_sock *msk,mptcp_for_each_subflow_safe (msk, subflow, tmp) {struct sock *ssk =mptcp_subflow_tcp_sock (subflow); +u8 remote_id =READ_ONCE (subflow->remote_id);int how =RCV_SHUTDOWN |SEND_SHUTDOWN ;u8 id =subflow_get_local_id (subflow); -if (rm_type ==MPTCP_MIB_RMADDR && subflow->remote_id != rm_id) +if (rm_type ==MPTCP_MIB_RMADDR && remote_id != rm_id)continue ;if (rm_type ==MPTCP_MIB_RMSUBFLOW && !mptcp_local_id_match (msk, id, rm_id))continue ;pr_debug (" -> %s rm_list_ids[%d]=%u local_id=%u remote_id=%u mpc_id=%u" , rm_type ==MPTCP_MIB_RMADDR ?"address" :"subflow" , - i, rm_id, id, subflow->remote_id, - msk->mpc_endpoint_id); + i, rm_id, id, remote_id, msk->mpc_endpoint_id);spin_unlock_bh (&msk->pm.lock);mptcp_subflow_shutdown (sk, ssk, how);
net/mptcp/subflow.c +3 -3
@@ -536,7 +536,7 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) subflow->backup = mp_opt.backup; subflow->thmac = mp_opt.thmac; subflow->remote_nonce = mp_opt.nonce; - subflow->remote_id = mp_opt.join_id; +WRITE_ONCE (subflow->remote_id, mp_opt.join_id);pr_debug ("subflow=%p, thmac=%llu, remote_nonce=%u backup=%d" , subflow, subflow->thmac, subflow->remote_nonce, subflow->backup);
@@ -1569,7 +1569,7 @@ int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc,pr_debug ("msk=%p remote_token=%u local_id=%d remote_id=%d" , msk, remote_token, local_id, remote_id); subflow->remote_token = remote_token; - subflow->remote_id = remote_id; +WRITE_ONCE (subflow->remote_id, remote_id); subflow->request_join =1 ; subflow->request_bkup = !!(flags &MPTCP_PM_ADDR_FLAG_BACKUP ); subflow->subflow_id = msk->subflow_id++;
@@ -1976,7 +1976,7 @@ static void subflow_ulp_clone(const struct request_sock *req, new_ctx->fully_established =1 ; new_ctx->remote_key_valid =1 ; new_ctx->backup = subflow_req->backup; - new_ctx->remote_id = subflow_req->remote_id; +WRITE_ONCE (new_ctx->remote_id, subflow_req->remote_id); new_ctx->token = subflow_req->token; new_ctx->thmac = subflow_req->thmac;
Signature · 1 line
2.43.0
Paolo Abeni
maintainerPATCH v2 4/4 mptcp: fix duplicate subflow creation
In reply to Paolo AbeniFullmesh 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.
---
v1 -> v2:
- forbit -> forbid
Note that there is no problem for the opposite event sequence.
--- net/mptcp/pm_netlink.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-)
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++; }
Signature · 1 line
2.43.0
Re: mptcp: fix duplicate subflow creation: Tests Results
Hi Paolo,
Thank you for your modifications, that's great!
Our CI (GitHub Action) did some validations and here is its report:
- KVM Validation: normal:
- Success! ✅:
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/7835837100
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/2770999be5bd
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normalFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
Re: mptcp: fix duplicate subflow creation: Tests Results
In reply to Paolo AbeniHi Paolo,
Thank you for your modifications, that's great!
Our CI (Cirrus) did some validations with a debug kernel and here is its report:
- KVM Validation: debug (except selftest_mptcp_join):
- Success! ✅:
- Task: https://cirrus-ci.com/task/4813501529587712
- Summary: https://api.cirrus-ci.com/v1/artifact/task/4813501529587712/summary/summary.txt
- KVM Validation: debug (only selftest_mptcp_join):
- Success! ✅:
- Task: https://cirrus-ci.com/task/5939401436430336
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5939401436430336/summary/summary.txt
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/2770999be5bd
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-debugFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
Re: mptcp: fix duplicate subflow creation: Tests Results
In reply to Paolo AbeniHi Paolo,
Thank you for your modifications, that's great!
Our CI (GitHub Action) did some validations and here is its report:
- KVM Validation: normal:
- Success! ✅:
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/7837946973
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/57268e5e5c3c
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normalFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
Re: mptcp: fix duplicate subflow creation: Tests Results
In reply to Paolo AbeniHi Paolo,
Thank you for your modifications, that's great!
Our CI (Cirrus) did some validations with a debug kernel and here is its report:
- KVM Validation: debug (except selftest_mptcp_join):
- Success! ✅:
- Task: https://cirrus-ci.com/task/5931257842892800
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5931257842892800/summary/summary.txt
- KVM Validation: debug (only selftest_mptcp_join):
- Success! ✅:
- Task: https://cirrus-ci.com/task/5109398167617536
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5109398167617536/summary/summary.txt
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/57268e5e5c3c
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-debugFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
Quoted 13 lines · Paolo Abeni
As reported by Mat, the in kernel PM can, in some edge scenarios, unexpectedly create multiple subflows with the same local and remote address.
The real fix is implemented by patch 4/4 with some more accurate check at subflow creation time.
Patches 1-3 are roughly optional pre-requisities, added to avoid introducing more data-races with the actual fix. Patch 1/4 is a bit debatable, as it changes the existing ULP API, but I could not find a better solution and there is some similar prior art:
commit0df48c26d841("tcp: addtcpi_bytes_ackedtotcp_info")
Quoted 9 lines
This address feedback from Mat on v1, see the patches changelog for the details (no changes in patch 1/4).
Paolo Abeni (4):
mptcp: fix lockless access in subflow ULP diag
mptcp: fix data races onlocal_id
mptcp: fix data races onremote_id
mptcp: fix duplicate subflow creation
Hi Paolo -
v2 LGTM, thanks:
Quoted 15 lines
include/net/tcp.h | 2 +- net/mptcp/diag.c | 8 +++++-- net/mptcp/pm_netlink.c | 45 +++++++++++++++++++++------------------- net/mptcp/pm_userspace.c | 2 +- net/mptcp/protocol.c | 2 +- net/mptcp/protocol.h | 15 +++++++++++--- net/mptcp/subflow.c | 15 +++++++------- net/tls/tls_main.c | 2 +- 8 files changed, 54 insertions(+), 37 deletions(-)Signature · 1 line
2.43.0
Matthieu Baerts
maintainerHi Paolo, Mat,
Quoted 7 lines · Paolo Abeni
As reported by Mat, the in kernel PM can, in some edge scenarios, unexpectedly create multiple subflows with the same local and remote address.
The real fix is implemented by patch 4/4 with some more accurate check at subflow creation time.
Quoted 8 lines
Patches 1-3 are roughly optional pre-requisities, added to avoid introducing more data-races with the actual fix. Patch 1/4 is a bit debatable, as it changes the existing ULP API, but I could not find a better solution and there is some similar prior art:
commit0df48c26d841("tcp: addtcpi_bytes_ackedtotcp_info")This address feedback from Mat on v1, see the patches changelog for the details (no changes in patch 1/4).
Thank you for the modifications and the reviews!
Now in our tree (fixes for -net):
New patches for t/upstream-net and t/upstream:
- ce4271cba41b: mptcp: fix lockless access in subflow ULP diag
- bb35405f2e28: mptcp: fix data races on local_id
- ed0e0e7b2325: mptcp: fix data races on remote_id
- 22e3b19337f7: mptcp: fix duplicate subflow creation
- Results: bef0b46af378..8abab82d59f2 (export-net)
- Results: 78a4d8e40bf5..0c8d1475f726 (export)
Tests are now in progress:
https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export-net/20240209T141835
https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20240209T141835
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.