From: Paolo Abeni <pabeni@redhat.com>
To: Matthieu Baerts <matthieu.baerts@tessares.net>, menglong8.dong@gmail.com
Cc: mathew.j.martineau@linux.intel.com, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, fw@strlen.de,
peter.krystad@linux.intel.com, netdev@vger.kernel.org,
mptcp@lists.linux.dev, linux-kernel@vger.kernel.org,
Menglong Dong <imagedong@tencent.com>,
Jiang Biao <benbjiang@tencent.com>,
Mengen Sun <mengensun@tencent.com>
Subject: Re: [PATCH net v3] net: mptcp: fix unreleased socket in accept queue
Date: Thu, 08 Sep 2022 16:44:58 +0200 [thread overview]
Message-ID: <52fcd27efafb415baa0bc52440296306110c56d7.camel@redhat.com> (raw)
In-Reply-To: <e4b7eddc-3a73-0994-467e-6d65d6ad80c0@tessares.net>
On Thu, 2022-09-08 at 15:56 +0200, Matthieu Baerts wrote:
> Hi Menglong,
>
> On 07/09/2022 13:11, 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.
>
> Thank you for the v3.
>
> Unfortunately, our CI found a possible recursive locking:
>
> > - KVM Validation: debug:
> > - Unstable: 1 failed test(s): selftest_mptcp_join - Critical: 1 Call Trace(s) ❌:
> > - Task: https://cirrus-ci.com/task/5418283233968128
> > - Summary: https://api.cirrus-ci.com/v1/artifact/task/5418283233968128/summary/summary.txt
>
> https://lore.kernel.org/mptcp/4e6d3d9e-1f1a-23ae-cb56-2d4f043f17ae@gmail.com/T/#u
>
> Do you mind looking at it please?
Ah, that is actually a false positive, but we must silence it. The main
point is that the lock_sock() in mptcp_close() rightfully lacks the
_nested annotation.
Instead of adding such annotation only for this call site, which would
be both ugly and dangerous, I suggest to factor_out from mptcp_close()
all the code the run under the socket lock, say in:
bool __mptcp_close(struct sock *sk, long timeout)
// return true if the caller need to cancel the mptcp worker
// (outside the socket lock)
and then in mptcp_subflow_queue_clean():
sock_hold(sk);
slow = lock_sock_fast_nested(sk);
next = msk->dl_next;
msk->first = NULL;
msk->dl_next = NULL;
do_cancel_work = __mptcp_close(sk, 0);
unlock_sock_fast(sk, slow);
if (do_cancel_work)
mptcp_cancel_work(sk);
sock_put(sk);
All the above could require 2 different patches, 1 to factor-out the
helper, and 1 to actually implement the fix.
Cheers,
Paolo
next prev parent reply other threads:[~2022-09-08 14:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-07 11:11 menglong8.dong
2022-09-08 13:56 ` Matthieu Baerts
2022-09-08 14:44 ` Paolo Abeni [this message]
2022-09-09 2:25 ` Menglong Dong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52fcd27efafb415baa0bc52440296306110c56d7.camel@redhat.com \
--to=pabeni@redhat.com \
--cc=benbjiang@tencent.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=imagedong@tencent.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathew.j.martineau@linux.intel.com \
--cc=matthieu.baerts@tessares.net \
--cc=mengensun@tencent.com \
--cc=menglong8.dong@gmail.com \
--cc=mptcp@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=peter.krystad@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®