mptcp: fix splat when closing unaccepted socket
Subsystems (2)
PATCH 1/1 mptcp: fix splat when closing unaccepted socket
From: Paolo Abeni <[email protected]>
If userspace exits before calling accept() on a listener that had at least one new connection ready, we get:
Attempt to release TCP socket in state 8
This happens because the mptcp socket gets cloned when the TCP connection is ready, but the socket is never exposed to userspace.
The client additionally sends a DATA_FIN, which brings connection into CLOSE_WAIT state. This in turn prevents the orphan+state reset fixup in mptcp_sock_destruct() from doing its job.
--- net/mptcp/subflow.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/mptcp/subflow.c +1 -2
@@ -546,8 +546,7 @@ static void mptcp_sock_destruct(struct sock *sk)* ESTABLISHED state and will not have the SOCK_DEAD flag. * Both result in warnings from inet_sock_destruct. */ - -if (sk->sk_state ==TCP_ESTABLISHED ) { +if ((1 << sk->sk_state) & (TCPF_ESTABLISHED |TCPF_CLOSE_WAIT )) { sk->sk_state =TCP_CLOSE ;WARN_ON_ONCE (sk->sk_socket);sock_orphan (sk);
Signature · 1 line
2.26.3
Quoted 38 lines · Florian Westphal
From: Paolo Abeni <[email protected]>
If userspace exits before calling
accept()on a listener that had at least one new connection ready, we get:Attempt to release TCP socket in state 8
This happens because the mptcp socket gets cloned when the TCP connection is ready, but the socket is never exposed to userspace.
The client additionally sends a
DATA_FIN, which brings connection intoCLOSE_WAITstate. This in turn prevents the orphan+state reset fixup inmptcp_sock_destruct()from doing its job.Fixes 3721b9b64676b ("mptcp: Track received DATA_FIN sequence number and add related helpers")Tested-by Florian Westphal <[email protected]>Signed-off-by Paolo Abeni <[email protected]>---
net/mptcp/subflow.c| 3 +--1 file changed, 1 insertion(+), 2 deletions(-)net/mptcp/subflow.c +1
-2@@ -546,8 +546,7 @@ static void mptcp_sock_destruct(struct sock *sk)* ESTABLISHED state and will not have the SOCK_DEAD flag. * Both result in warnings from inet_sock_destruct. */ - -if (sk->sk_state ==TCP_ESTABLISHED ) { +if ((1 << sk->sk_state) & (TCPF_ESTABLISHED |TCPF_CLOSE_WAIT )) { sk->sk_state =TCP_CLOSE ;WARN_ON_ONCE (sk->sk_socket);sock_orphan (sk);Signature · 1 line
2.26.3
Thanks Paolo and Florian. Patch looks good - should go to -net right?
--
Mat Martineau
Intel
Quoted 1 line · Mat Martineau
Thanks Paolo and Florian. Patch looks good - should go to -net right?
Yes, this needs to go to -net.
Thanks!
Hi Florian, Paolo, Mat,
Quoted 10 lines · Florian Westphal
From: Paolo Abeni <[email protected]>
If userspace exits before calling
accept()on a listener that had at least one new connection ready, we get:Attempt to release TCP socket in state 8
This happens because the mptcp socket gets cloned when the TCP connection is ready, but the socket is never exposed to userspace.
Quoted 8 lines
The client additionally sends a
DATA_FIN, which brings connection intoCLOSE_WAITstate. This in turn prevents the orphan+state reset fixup inmptcp_sock_destruct()from doing its job.Fixes 3721b9b64676b ("mptcp: Track received DATA_FIN sequence number and add related helpers")Tested-by Florian Westphal <[email protected]>Signed-off-by Paolo Abeni <[email protected]>
Thank you for the patch and the review.
Now in our tree with Mat's RvB tag:
- eb5185213368: mptcp: fix splat when closing unaccepted socket
- Results: f6df9e9d3336..9c59ba276e75
Builds and tests are now in progress:
https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20210504T064955
https://github.com/multipath-tcp/mptcp_net-next/actions/workflows/build-validation.yml?query=branch:export/20210504T064955
Cheers,
Matt
Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions www.tessares.net