From: Florian Westphal <fw@strlen.de>
To: Thomas Jarosch <thomas.jarosch@intra2net.com>
Cc: Florian Westphal <fw@strlen.de>,
netdev@vger.kernel.org, netfilter-devel@vger.kernel.org,
Juliana Rodrigueiro <juliana.rodrigueiro@intra2net.com>
Subject: Re: 4.19: Traced deadlock during xfrm_user module load
Date: Thu, 27 Jun 2019 17:50:36 +0200 [thread overview]
Message-ID: <20190627155036.vzoo2xikdfuyiug3@breakpoint.cc> (raw)
In-Reply-To: <20190627154629.27g5uwd47esyhz4s@intra2net.com>
Thomas Jarosch <thomas.jarosch@intra2net.com> wrote:
> You wrote on Tue, Jun 25, 2019 at 06:53:44PM +0200:
> > Thanks for this detailed analysis.
> > In this specific case I think this is enough:
> >
> > diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
> > index 92077d459109..61ba92415480 100644
> > --- a/net/netfilter/nfnetlink.c
> > +++ b/net/netfilter/nfnetlink.c
> > @@ -578,7 +578,8 @@ static int nfnetlink_bind(struct net *net, int group)
> > ss = nfnetlink_get_subsys(type << 8);
> > rcu_read_unlock();
> > if (!ss)
> > - request_module("nfnetlink-subsys-%d", type);
> > + request_module_nowait("nfnetlink-subsys-%d", type);
> > return 0;
> > }
> > #endif
>
> thanks for the patch! We finally found an easy way to reproduce the deadlock,
> the following commands instantly trigger the problem on our machines:
>
> rmmod nf_conntrack_netlink
> rmmod xfrm_user
> conntrack -e NEW -E & modprobe -v xfrm_user
>
> Note: the "-e" filter is needed to trigger the problematic
> code path in the kernel.
>
> We were worried that using "_nowait" would introduce other race conditions,
> since the requested service might not be available by the time it is required.
Then this code would be buggy too, there is no guarantee that a
request_module() succeeds.
> "nfnetlink_bind()", the caller will listen on the socket for messages
> regardless whether the needed modules are loaded, loading or unloaded.
> To verify this we added a three second sleep during the initialisation of
> nf_conntrack_netlink. The events started to appear after
> the delayed init was completed.
>
> If this is the case, then using "_nowait" should suffice as a fix
> for the problem. Could you please confirm these assumptions
> and give us some piece of mind?
Yes, _nowait is safe here (and needed, as you find out).
I'm away for a few hours but I plan to submit this patch officially
soon.
prev parent reply other threads:[~2019-06-27 15:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-25 15:55 4.19: Traced deadlock during xfrm_user module load Thomas Jarosch
2019-06-25 16:53 ` Florian Westphal
2019-06-27 15:46 ` Thomas Jarosch
2019-06-27 15:50 ` Florian Westphal [this message]
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=20190627155036.vzoo2xikdfuyiug3@breakpoint.cc \
--to=fw@strlen.de \
--cc=juliana.rodrigueiro@intra2net.com \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=thomas.jarosch@intra2net.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