[PATCH net v5 0/2] net: mptcp: fix unreleased socket in accept queue

menglong8.dong@gmail.com posted 2 patches 2 weeks, 2 days ago
Failed in applying to current master (apply log)
net/mptcp/protocol.c | 16 +++++++++++++---
net/mptcp/protocol.h |  2 ++
net/mptcp/subflow.c  | 33 +++++++--------------------------
3 files changed, 22 insertions(+), 29 deletions(-)
[PATCH net v5 0/2] net: mptcp: fix unreleased socket in accept queue
Posted by menglong8.dong@gmail.com 2 weeks, 2 days ago
From: Menglong Dong <imagedong@tencent.com>

The mptcp socket and its subflow sockets in accept queue can't be
released after the process exit.

While the release of a mptcp socket in listening state, the
corresponding tcp socket will be released too. Meanwhile, the tcp
socket in the unaccept queue will be released too. However, only init
subflow is in the unaccept queue, and the joined subflow is not in the
unaccept queue, which makes the joined subflow won't be released, and
therefore the corresponding unaccepted mptcp socket will not be released
to.

In the 1th patch, we factor-out __mptcp_close() which should run under
socket lock.

And in the 2th patch, we fix the problem we mentioned above by closing
all of the unaccepted mptcp socket in mptcp_subflow_queue_clean()
with __mptcp_close().

Changes since v4:
- keep sock_hold() in __mptcp_close() in the 1th patch
- rename cancel_work to do_cancel_work in the 1th patch
- don't make mptcp_cancel_work() inline in the 2th patch

Changes since v3:
- factor out __mptcp_close() and replace mptcp_close() with it in
  mptcp_subflow_queue_clean()

Menglong Dong (2):
  net: mptcp: factor out __mptcp_close() without socket lock
  net: mptcp: fix unreleased socket in accept queue

 net/mptcp/protocol.c | 16 +++++++++++++---
 net/mptcp/protocol.h |  2 ++
 net/mptcp/subflow.c  | 33 +++++++--------------------------
 3 files changed, 22 insertions(+), 29 deletions(-)

-- 
2.37.2
Re: [PATCH net v5 0/2] net: mptcp: fix unreleased socket in accept queue
Posted by Paolo Abeni 1 week, 1 day ago
On Sun, 2022-09-11 at 12:14 +0800, menglong8.dong@gmail.com wrote:
> From: Menglong Dong <imagedong@tencent.com>
> 
> The mptcp socket and its subflow sockets in accept queue can't be
> released after the process exit.
> 
> While the release of a mptcp socket in listening state, the
> corresponding tcp socket will be released too. Meanwhile, the tcp
> socket in the unaccept queue will be released too. However, only init
> subflow is in the unaccept queue, and the joined subflow is not in the
> unaccept queue, which makes the joined subflow won't be released, and
> therefore the corresponding unaccepted mptcp socket will not be released
> to.
> 
> In the 1th patch, we factor-out __mptcp_close() which should run under
> socket lock.
> 
> And in the 2th patch, we fix the problem we mentioned above by closing
> all of the unaccepted mptcp socket in mptcp_subflow_queue_clean()
> with __mptcp_close().
> 
> Changes since v4:
> - keep sock_hold() in __mptcp_close() in the 1th patch
> - rename cancel_work to do_cancel_work in the 1th patch
> - don't make mptcp_cancel_work() inline in the 2th patch
> 
> Changes since v3:
> - factor out __mptcp_close() and replace mptcp_close() with it in
>   mptcp_subflow_queue_clean()
> 
> Menglong Dong (2):
>   net: mptcp: factor out __mptcp_close() without socket lock
>   net: mptcp: fix unreleased socket in accept queue
> 
>  net/mptcp/protocol.c | 16 +++++++++++++---
>  net/mptcp/protocol.h |  2 ++
>  net/mptcp/subflow.c  | 33 +++++++--------------------------
>  3 files changed, 22 insertions(+), 29 deletions(-)

I think this is now even a nice cleanup, beyond a relevant bug-fix,
thanks!

For the series:

Acked-by: Paolo Abeni <pabeni@redhat.com>
Re: [PATCH net v5 0/2] net: mptcp: fix unreleased socket in accept queue
Posted by Matthieu Baerts 1 week, 1 day ago
Hi Menglong, Paolo,

On 11/09/2022 06:14, menglong8.dong@gmail.com wrote:
> From: Menglong Dong <imagedong@tencent.com>
> 
> The mptcp socket and its subflow sockets in accept queue can't be
> released after the process exit.
> 
> While the release of a mptcp socket in listening state, the
> corresponding tcp socket will be released too. Meanwhile, the tcp
> socket in the unaccept queue will be released too. However, only init
> subflow is in the unaccept queue, and the joined subflow is not in the
> unaccept queue, which makes the joined subflow won't be released, and
> therefore the corresponding unaccepted mptcp socket will not be released
> to.
> 
> In the 1th patch, we factor-out __mptcp_close() which should run under
> socket lock.
> 
> And in the 2th patch, we fix the problem we mentioned above by closing
> all of the unaccepted mptcp socket in mptcp_subflow_queue_clean()
> with __mptcp_close().

Thank you for the patches and the reviews!

This series is now in our tree (fix for -net) with Paolo's ACK and
without one typo found by "checkpatch.pl --codespell" and 'net:' prefix
has been strip from the commit titles ('mptcp:' is enough)

New patches for t/upstream-net:
- 8c21b4904d34: mptcp: factor out __mptcp_close() without socket lock
- f00ac22032b8: mptcp: fix unreleased socket in accept queue
- Results: 69b3bebab7a6..2882a52515ba (export-net)

New patches for t/upstream:
- 8c21b4904d34: mptcp: factor out __mptcp_close() without socket lock
- f00ac22032b8: mptcp: fix unreleased socket in accept queue
- Results: 6cd726fd86f8..6c59a4b0aee6 (export)


Tests are now in progress:

https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export-net/20220919T151225
https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20220919T151225


Cheers,
Matt
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net