Skip to contentSkip to conversation

mptcp: fix extra_subflows leak on failed passive join

PATCH Superseded Chenguang Zhao 4 participants 9 messages Jun 30 – Jul 21

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mptcp: fix extra_subflows leak on failed passive join

From: Chenguang Zhao <[email protected]>

mptcp_pm_allow_new_subflow() increments extra_subflows before __mptcp_finish_join() on the passive MP_JOIN path. On synchronous join failure the subflow is dropped without calling mptcp_close_ssk(), so the counter is not rolled back.

Call mptcp_pm_close_subflow() when the join completion fails.

---
 net/mptcp/protocol.c | 1 +
 1 file changed, 1 insertion(+)
net/mptcp/protocol.c +1 -0
index cb9515f505aa..b32f0cd262a7 100644
@@ -3907,6 +3907,7 @@ bool mptcp_finish_join(struct sock *ssk)
 	mptcp_data_unlock(parent);
 
 	if (!ret) {
+		mptcp_pm_close_subflow(msk);
 err_prohibited:
 		subflow->reset_reason = MPTCP_RST_EPROHIBIT;
 		return false;
Signature · 1 line
2.25.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi Chenguang,

Thank you for the fix.

Quoted 2 lines

mptcp_pm_allow_new_subflow() increments extra_subflows before __mptcp_finish_join() on the passive MP_JOIN path.

I see that this code path is currently not exercised by our test suite:

https://ci-results.mptcp.dev/lcov/export/mptcp/protocol.c.gcov.html#L4031

How did you spot the issue? Do you have a reproducer? Or was it by reading the code? Assisted by a tool (in this case, please add the Assisted-by tag)?

I see we have a test for sync connect failure, but not sync join. Do you mind adding a new Packetdrill test please? Similar to simult_connect.pkt I suppose:

https://github.com/multipath-tcp/packetdrill/blob/mptcp-net-next/gtests/net/mptcp/syscalls/simult_connect.pkt

Quoted 4 lines

On synchronous join failure the subflow is dropped without calling mptcp_close_ssk(), so the counter is not rolled back.

Call mptcp_pm_close_subflow() when the join completion fails.

A fix patch should always have a Fixes tag. Here, I guess it should be:

Fixes 10f6d46c943d ("mptcp: fix race between MP_JOIN and close")

Apart from that, the modification looks good to me:

Signature · 1 line
Matthieu Baerts (NGI0) <[email protected]>
#2 lore raw

Hi Matthieu,

Regarding the sync join failure, I have already submitted a PR.
https://github.com/multipath-tcp/packetdrill/pull/200

Thanks

Quoted 32 lines · Matthieu Baerts

Hi Chenguang,

Thank you for the fix.

Quoted 2 lines

mptcp_pm_allow_new_subflow() increments extra_subflows before __mptcp_finish_join() on the passive MP_JOIN path.

I see that this code path is currently not exercised by our test suite:

https://ci-results.mptcp.dev/lcov/export/mptcp/protocol.c.gcov.html#L4031

How did you spot the issue? Do you have a reproducer? Or was it by reading the code? Assisted by a tool (in this case, please add the Assisted-by tag)?

I see we have a test for sync connect failure, but not sync join. Do you mind adding a new Packetdrill test please? Similar to simult_connect.pkt I suppose:

https://github.com/multipath-tcp/packetdrill/blob/mptcp-net-next/gtests/net/mptcp/syscalls/simult_connect.pkt

Quoted 4 lines

On synchronous join failure the subflow is dropped without calling mptcp_close_ssk(), so the counter is not rolled back.

Call mptcp_pm_close_subflow() when the join completion fails.

A fix patch should always have a Fixes tag. Here, I guess it should be:

Fixes 10f6d46c943d ("mptcp: fix race between MP_JOIN and close")

Apart from that, the modification looks good to me:

#3 lore raw
In reply to Chenguang Zhao

Hi Chenguang,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal (except selftest_mptcp_join): Success! ✅
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Success! ✅
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/28438179349

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/654ae3cf6532
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1118853

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-normal

For 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)

#4 lore raw

PATCH v2 1/1 mptcp: fix extra_subflows leak on failed passive join

In reply to Chenguang Zhao

From: Chenguang Zhao <[email protected]>

mptcp_pm_allow_new_subflow() increments extra_subflows before __mptcp_finish_join() on the passive MP_JOIN path. On synchronous join failure the subflow is dropped without calling mptcp_close_ssk(), so the counter is not rolled back.

Call mptcp_pm_close_subflow() when the join completion fails.

Fixes 3e5014909b56 ("mptcp: cleanup MPJ subflow list handling")

---
v2:
Hi Matthieu,
Thanks for the review.
- I spotted this by reading the code. I don't have a reproducer yet. I also see we already have a Packetdrill test for synchronous connect failure (simult_connect.pkt), but not for synchronous join failure. I'll add a similar Packetdrill test
for that case and send it in a follow-up patch.
- Add Fixes and Reviewd-by tag.
- I looked again at the history, and I think the Fixes tag
should point to 3e5014909b56 ("mptcp: cleanup MPJ subflow list handling"), not 10f6d46c943d ("mptcp: fix race between MP_JOIN and close").
v1:
- https://lore.kernel.org/all/[email protected]/

 net/mptcp/protocol.c | 1 +
 1 file changed, 1 insertion(+)
net/mptcp/protocol.c +1 -0
index cb9515f505aa..b32f0cd262a7 100644
@@ -3907,6 +3907,7 @@ bool mptcp_finish_join(struct sock *ssk)
 	mptcp_data_unlock(parent);
 
 	if (!ret) {
+		mptcp_pm_close_subflow(msk);
 err_prohibited:
 		subflow->reset_reason = MPTCP_RST_EPROHIBIT;
 		return false;
Signature · 1 line
2.25.1
#5 lore raw

Hi Chenguang,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal (except selftest_mptcp_join): Success! ✅
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Success! ✅
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/28491654012

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/4d3b1813957d
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1119370

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-normal

For 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)

reviewer
#6 lore raw
In reply to Chenguang Zhao

Hi Chenguang,

Thanks for this v2. However, if there are no code changes, there is no need to send a v2; we can just reply to the email thread on v1 to discuss it.

Quoted 12 lines · Chenguang Zhao

From: Chenguang Zhao <[email protected]>

mptcp_pm_allow_new_subflow() increments extra_subflows before __mptcp_finish_join() on the passive MP_JOIN path. On synchronous join failure the subflow is dropped without calling mptcp_close_ssk(), so the counter is not rolled back.

Call mptcp_pm_close_subflow() when the join completion fails.

Fixes 3e5014909b56 ("mptcp: cleanup MPJ subflow list handling")
Quoted 14 lines

---
v2:
 Hi Matthieu,
 Thanks for the review.
 - I spotted this by reading the code. I don't have a reproducer yet. I also see we already have a Packetdrill test for synchronous connect failure (simult_connect.pkt), but not for synchronous join failure. I'll add a similar Packetdrill test for that case and send it in a follow-up patch.
 - Add Fixes and Reviewd-by tag.
 - I looked again at the history, and I think the Fixes tag should point to 3e5014909b56 ("mptcp: cleanup MPJ subflow list handling"), not 10f6d46c943d ("mptcp: fix race between MP_JOIN and close").

The Fixes tag is incorrect and should be 10f6d46c943d ("mptcp: fix race between MP_JOIN and close"), because that commit introduced the call to mptcp_pm_allow_new_subflow. There is no need to send a v3, as this can be updated when applying.

I have changed the status of v2 to "Queued" and v1 to "Superseded".

Thanks,
-Geliang

Quoted 19 lines

v1:
 -
https://lore.kernel.org/all/[email protected]/

 net/mptcp/protocol.c | 1 +

 1 file changed, 1 insertion(+)
net/mptcp/protocol.c +0 -0
index cb9515f505aa..b32f0cd262a7 100644
@@ -3907,6 +3907,7 @@ bool mptcp_finish_join(struct sock *ssk)
  	mptcp_data_unlock(parent);


  if (!ret) {

net/mptcp/protocol.c +1 -0
+		mptcp_pm_close_subflow(msk);

 err_prohibited:
  subflow->reset_reason = MPTCP_RST_EPROHIBIT; return false;

maintainer
#7 lore raw

Hi Geliang, Chenguang,

Quoted 5 lines · Geliang Tang

Hi Chenguang,

Thanks for this v2. However, if there are no code changes, there is no need to send a v2; we can just reply to the email thread on v1 to discuss it.

Indeed. Also, it is easier if you start a new thread with a link to the previous version, than replying to a previous version.

Quoted 7 lines · Chenguang Zhao
Quoted 6 lines

From: Chenguang Zhao <[email protected]>

mptcp_pm_allow_new_subflow() increments extra_subflows before __mptcp_finish_join() on the passive MP_JOIN path. On synchronous join failure the subflow is dropped without calling mptcp_close_ssk(), so the counter is not rolled back.

What do you mean by saying "On synchronous join failure"? When I look at the packetdrill test, we are not talking about synchronous MP_JOIN (SYN
+ MP_JOIN packets in both directions), right?

Quoted 20 lines
Quoted 5 lines

Call mptcp_pm_close_subflow() when the join completion fails.

Fixes 3e5014909b56 ("mptcp: cleanup MPJ subflow list handling")
Quoted 14 lines

---
v2:
 Hi Matthieu,
 Thanks for the review.
 - I spotted this by reading the code. I don't have a reproducer yet. I also see we already have a Packetdrill test for synchronous connect failure (simult_connect.pkt), but not for synchronous join failure. I'll add a similar Packetdrill test for that case and send it in a follow-up patch.
 - Add Fixes and Reviewd-by tag.
 - I looked again at the history, and I think the Fixes tag should point to 3e5014909b56 ("mptcp: cleanup MPJ subflow list handling"), not 10f6d46c943d ("mptcp: fix race between MP_JOIN and close").

Quoted 4 lines

The Fixes tag is incorrect and should be 10f6d46c943d ("mptcp: fix race between MP_JOIN and close"), because that commit introduced the call to mptcp_pm_allow_new_subflow. There is no need to send a v3, as this can be updated when applying.

+1

Quoted 1 line

I have changed the status of v2 to "Queued" and v1 to "Superseded".

I will wait to get the packetdrill test ready before applying this patch.

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
maintainer
#8 lore raw
In reply to Chenguang Zhao

Hi Chenguang,

Quoted 7 lines · Chenguang Zhao

From: Chenguang Zhao <[email protected]>

mptcp_pm_allow_new_subflow() increments extra_subflows before __mptcp_finish_join() on the passive MP_JOIN path. On synchronous join failure the subflow is dropped without calling mptcp_close_ssk(), so the counter is not rolled back.

Quoted 5 lines

Call mptcp_pm_close_subflow() when the join completion fails.

Fixes 3e5014909b56 ("mptcp: cleanup MPJ subflow list handling")

Thank you for the patch. Now in our tree (with small adaptations in the commit message):

New patches for t/upstream-net and t/upstream:
- 5cc023a79ad5: mptcp: decrement subflows counter on failed passive join
- Results: 6e75226ac108..4c2362a7db02 (export-net)
- Results: 4c2752580a3e..4285a4fe811b (export)

Tests are now in progress:

- export-net:
https://github.com/multipath-tcp/mptcp_net-next/commit/bc033e934bd44ead5a065f26cb78af76769e90de/checks
- export:
https://github.com/multipath-tcp/mptcp_net-next/commit/254350c480d5cc9124500ba3588f2d24a1905608/checks

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.