Skip to contentSkip to conversation

mptcp: really cope with fastopen race.

PATCH In review Paolo Abeni 4 participants 11 messages Jan 24, 2024 – Feb 5, 2024

Subsystems (2)
lore
Share & tools
lore

Paolo Abeni

author maintainer
#0 lore raw

PATCH 1/1 mptcp: really cope with fastopen race.

Fastopen and PM-trigger subflow shutdown can race, as reported by syzkaller.

In my first attempt to close such race, I missed the fact that the subflow status can change again before the subflow_state_change callback is invoked.

Address the issue additionally copying with all the states directly reachable from TCP_FIN_WAIT1.

Fixes 1e777f39b4d7 ("mptcp: add MSG_FASTOPEN sendmsg flag support")
Fixes 4fd19a307016 ("mptcp: fix inconsistent state on fastopen race")
Reported-by [email protected]
---
 net/mptcp/protocol.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/mptcp/protocol.h +2 -1
index 4a32d3d11fb6..de04b97e8dd1 100644
@@ -1171,7 +1171,8 @@ static inline bool subflow_simultaneous_connect(struct sock *sk)
 {
 	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
 
-	return (1 << sk->sk_state) & (TCPF_ESTABLISHED | TCPF_FIN_WAIT1) &&
+	return (1 << sk->sk_state) &
+	       (TCPF_ESTABLISHED | TCPF_FIN_WAIT1 | TCPF_FIN_WAIT2 | TCPF_CLOSING) &&
 	       is_active_ssk(subflow) &&
 	       !subflow->conn_finished;
 }
Signature · 1 line
2.43.0
#1 lore raw

Re: mptcp: really cope with fastopen race.: 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:
- Unstable: 2 failed test(s): packetdrill_regressions selftest_mptcp_join 🔴:
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/7646707610

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/f24f750c6f62

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)

#2 lore raw

Re: mptcp: really cope with fastopen race.: Tests Results

In reply to Paolo Abeni

Hi 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):
- Critical: 1 Call Trace(s) ❌:
- Task: https://cirrus-ci.com/task/5675809764016128
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5675809764016128/summary/summary.txt

- KVM Validation: debug (only selftest_mptcp_join):
- Critical: 1 Call Trace(s) ❌:
- Task: https://cirrus-ci.com/task/5112859810594816
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5112859810594816/summary/summary.txt

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/f24f750c6f62

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

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)

maintainer Reviewed-by on v1 1/1
#3 lore raw
In reply to Paolo Abeni
Quoted 7 lines · Paolo Abeni

Fastopen and PM-trigger subflow shutdown can race, as reported by syzkaller.

In my first attempt to close such race, I missed the fact that the subflow status can change again before the subflow_state_change callback is invoked.

Quoted 7 lines

Address the issue additionally copying with all the states directly reachable from TCP_FIN_WAIT1.

Fixes 1e777f39b4d7 ("mptcp: add MSG_FASTOPEN sendmsg flag support")
Fixes 4fd19a307016 ("mptcp: fix inconsistent state on fastopen race")
Reported-by [email protected]

I wasn't able to reproduce the CI failure, and the change looks good to me. We'll see if CI is happy when this is applied to export-net.

Quoted 23 lines

---
net/mptcp/protocol.h | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
net/mptcp/protocol.h +2 -1
index 4a32d3d11fb6..de04b97e8dd1 100644
@@ -1171,7 +1171,8 @@ static inline bool subflow_simultaneous_connect(struct sock *sk)
 {
 	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
 
-	return (1 << sk->sk_state) & (TCPF_ESTABLISHED | TCPF_FIN_WAIT1) &&
+	return (1 << sk->sk_state) &
+	       (TCPF_ESTABLISHED | TCPF_FIN_WAIT1 | TCPF_FIN_WAIT2 | TCPF_CLOSING) &&
 	       is_active_ssk(subflow) &&
 	       !subflow->conn_finished;
 }
Signature · 1 line
2.43.0
author maintainer
#4 lore raw
Quoted 12 lines · Mat Martineau
Quoted 10 lines · Paolo Abeni

Fastopen and PM-trigger subflow shutdown can race, as reported by syzkaller.

In my first attempt to close such race, I missed the fact that the subflow status can change again before the subflow_state_change callback is invoked.

Address the issue additionally copying with all the states directly reachable from TCP_FIN_WAIT1.

Quoted 7 lines
Quoted 4 lines
Fixes 1e777f39b4d7 ("mptcp: add MSG_FASTOPEN sendmsg flag support")
Fixes 4fd19a307016 ("mptcp: fix inconsistent state on fastopen race")
Reported-by [email protected]

I wasn't able to reproduce the CI failure, and the change looks good to me. We'll see if CI is happy when this is applied to export-net.

I used the repro provided by syzbot upstream:

https://lore.kernel.org/netdev/[email protected]/
https://syzkaller.appspot.com/x/repro.c?x=17abc23be80000

with my default debug config, and here it reproduced the issue reliably on the unpatched kernel (and no splat with the patched one).

Quoted 2 lines

Thanks,

Paolo

maintainer
#5 lore raw
Quoted 21 lines · Paolo Abeni
Quoted 12 lines · Mat Martineau
Quoted 10 lines · Paolo Abeni

Fastopen and PM-trigger subflow shutdown can race, as reported by syzkaller.

In my first attempt to close such race, I missed the fact that the subflow status can change again before the subflow_state_change callback is invoked.

Address the issue additionally copying with all the states directly reachable from TCP_FIN_WAIT1.

Quoted 7 lines
Quoted 4 lines
Fixes 1e777f39b4d7 ("mptcp: add MSG_FASTOPEN sendmsg flag support")
Fixes 4fd19a307016 ("mptcp: fix inconsistent state on fastopen race")
Reported-by [email protected]

I wasn't able to reproduce the CI failure, and the change looks good to me. We'll see if CI is happy when this is applied to export-net.

Quoted 8 lines

I used the repro provided by syzbot upstream:

https://lore.kernel.org/netdev/[email protected]/
https://syzkaller.appspot.com/x/repro.c?x=17abc23be80000

with my default debug config, and here it reproduced the issue reliably on the unpatched kernel (and no splat with the patched one).

I was not very specific in my wording: I was referring to the CI failures when it applied this patch to export-net:

https://lore.kernel.org/mptcp/[email protected]/T/#mfb81b40b8a42912362eede622b5a15b17313d2a2

...not the failure reported by syzbot that this patch is intended to fix.

I did run export-net plus this patch through the mptcp-upstream-virtme-docker environment and it worked fine, so I think it's ok to apply.

- Mat

author maintainer
#6 lore raw
Quoted 28 lines · Mat Martineau
Quoted 26 lines · Paolo Abeni
Quoted 12 lines · Mat Martineau
Quoted 10 lines · Paolo Abeni

Fastopen and PM-trigger subflow shutdown can race, as reported by syzkaller.

In my first attempt to close such race, I missed the fact that the subflow status can change again before the subflow_state_change callback is invoked.

Address the issue additionally copying with all the states directly reachable from TCP_FIN_WAIT1.

Quoted 7 lines
Quoted 4 lines
Fixes 1e777f39b4d7 ("mptcp: add MSG_FASTOPEN sendmsg flag support")
Fixes 4fd19a307016 ("mptcp: fix inconsistent state on fastopen race")
Reported-by [email protected]

I wasn't able to reproduce the CI failure, and the change looks good to me. We'll see if CI is happy when this is applied to export-net.

I used the repro provided by syzbot upstream:

https://lore.kernel.org/netdev/[email protected]/
https://syzkaller.appspot.com/x/repro.c?x=17abc23be80000

Quoted 8 lines
Quoted 3 lines

with my default debug config, and here it reproduced the issue reliably on the unpatched kernel (and no splat with the patched one).

I was not very specific in my wording: I was referring to the CI failures when it applied this patch to export-net:

https://lore.kernel.org/mptcp/[email protected]/T/#mfb81b40b8a42912362eede622b5a15b17313d2a2

Ah, that one!

I think it's caused by:

commit 198bc90e0e734e5f98c3d2833e8390cac3df61b2

Author: Zhengchao Shao <[email protected]>
Date:   Thu Jan 18 09:20:19 2024 +0800

tcp: make sure init the accept_queue's spinlocks once

and fixed by:

commit 435e202d645c197dcfd39d7372eb2a56529b6640 (net68/tmp_png)

Author: Zhengchao Shao <[email protected]>
Date:   Mon Jan 22 18:20:01 2024 +0800

ipv6: init the accept_queue's spinlocks in inet6_create

Cheers,

Paolo

#7 lore raw

Re: mptcp: really cope with fastopen race.: Tests Results

In reply to Paolo Abeni

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:
- Unstable: 2 failed test(s): packetdrill_mp_reset packetdrill_regressions 🔴:
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/7675409892

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/00a670cc257a

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)

#8 lore raw

Re: mptcp: really cope with fastopen race.: Tests Results

In reply to Paolo Abeni

Hi 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/4896041841983488
- Summary: https://api.cirrus-ci.com/v1/artifact/task/4896041841983488/summary/summary.txt

- KVM Validation: debug (only selftest_mptcp_join):
- Unstable: 1 failed test(s): selftest_mptcp_join 🔴:
- Task: https://cirrus-ci.com/task/6021941748826112
- Summary: https://api.cirrus-ci.com/v1/artifact/task/6021941748826112/summary/summary.txt

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/00a670cc257a

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

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)

maintainer
#9 lore raw
In reply to Paolo Abeni

Hi Paolo, Mat,

Quoted 9 lines · Paolo Abeni

Fastopen and PM-trigger subflow shutdown can race, as reported by syzkaller.

In my first attempt to close such race, I missed the fact that the subflow status can change again before the subflow_state_change callback is invoked.

Address the issue additionally copying with all the states directly reachable from TCP_FIN_WAIT1.

Thank you for the patch and the review!

Now in our tree (fix for -net) without the '.' at the end of the commit title and a Closes tag ;)

New patches for t/upstream-net and t/upstream:
- d59403d0c91b: mptcp: really cope with fastopen race
- Results: ca82f8ccb3cc..6d56aa24e733 (export-net)
- Results: 4b8f1ec22243..cdd4fe00f4c5 (export)

Tests are now in progress:

https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export-net/20240130T120521
https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20240130T120521

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
author maintainer
#10 lore raw
In reply to Paolo Abeni
Quoted 7 lines · Paolo Abeni

Fastopen and PM-trigger subflow shutdown can race, as reported by syzkaller.

In my first attempt to close such race, I missed the fact that the subflow status can change again before the subflow_state_change callback is invoked.

Quoted 6 lines

Address the issue additionally copying with all the states directly reachable from TCP_FIN_WAIT1.

Fixes 1e777f39b4d7 ("mptcp: add MSG_FASTOPEN sendmsg flag support")
Fixes 4fd19a307016 ("mptcp: fix inconsistent state on fastopen race")
Reported-by [email protected]

Hopefully it's not too late...

The above should be:

Reported-by [email protected]

@Mat(s), could you please update the path directly in the export branch?

Thanks!

Paolo