From: Peter Zijlstra <peterz@infradead.org>
To: Will Deacon <will@kernel.org>
Cc: Florian Westphal <fw@strlen.de>,
Kajetan Puchalski <kajetan.puchalski@arm.com>,
Pablo Neira Ayuso <pablo@netfilter.org>,
Jozsef Kadlecsik <kadlec@netfilter.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Mel Gorman <mgorman@suse.de>,
lukasz.luba@arm.com, dietmar.eggemann@arm.com,
mark.rutland@arm.com, broonie@kernel.org,
netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
netdev@vger.kernel.org, stable@vger.kernel.org,
regressions@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [Regression] stress-ng udp-flood causes kernel panic on Ampere Altra
Date: Wed, 6 Jul 2022 16:00:58 +0200 [thread overview]
Message-ID: <YsWVmrMA6aFE8oDr@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20220706122246.GI2403@willie-the-truck>
On Wed, Jul 06, 2022 at 01:22:50PM +0100, Will Deacon wrote:
> > @@ -300,6 +300,9 @@ static inline bool nf_ct_is_expired(const struct nf_conn *ct)
> > /* use after obtaining a reference count */
> > static inline bool nf_ct_should_gc(const struct nf_conn *ct)
> > {
> > + /* ->status and ->timeout loads must happen after refcount increase */
> > + smp_rmb();
>
> Sorry I didn't suggest this earlier, but if all of these smp_rmb()s are
> for upgrading the ordering from refcount_inc_not_zero() then you should
> use smp_acquire__after_ctrl_dep() instead. It's the same under the hood,
> but it illustrates what's going on a bit better.
But in that case if had better also be near an actual condition,
otherwise things become too murky for words :/
That is, why is this sprinkled all over instead of right after
an successfull refcount_inc_not_zero() ?
Code like:
if (!refcount_inc_not_zero())
return;
smp_acquire__after_ctrl_dep();
is fairly self-evident, whereas encountering an
smp_acquire__after_ctrl_dep() in a different function, completely
unrelated to any condition is quite crazy.
> > @@ -1775,6 +1784,16 @@ init_conntrack(struct net *net, struct nf_conn *tmpl,
> > if (!exp)
> > __nf_ct_try_assign_helper(ct, tmpl, GFP_ATOMIC);
> >
> > + /* Other CPU might have obtained a pointer to this object before it was
> > + * released. Because refcount is 0, refcount_inc_not_zero() will fail.
> > + *
> > + * After refcount_set(1) it will succeed; ensure that zeroing of
> > + * ct->status and the correct ct->net pointer are visible; else other
> > + * core might observe CONFIRMED bit which means the entry is valid and
> > + * in the hash table, but its not (anymore).
> > + */
> > + smp_wmb();
> > +
> > /* Now it is going to be associated with an sk_buff, set refcount to 1. */
> > refcount_set(&ct->ct_general.use, 1);
>
> Ideally that refcount_set() would be a release, but this is definitely
> (ab)using refcount_t in way that isn't anticipated by the API! It looks
> like a similar pattern exists in net/core/sock.c as well, so I wonder if
> it's worth extending the API.
>
> Peter, what do you think?
Bah; you have reminded me that I have a fairly sizable amount of
refcount patches from when Linus complained about it last that don't
seem to have gone anywhere :/
Anyway, I suppose we could do a refcount_set_release(), but it had
better get a fairly big comment on how you're on your own if you use it.
prev parent reply other threads:[~2022-07-06 14:01 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-01 11:11 [Regression] stress-ng udp-flood causes kernel panic on Ampere Altra Kajetan Puchalski
2022-07-01 11:42 ` [Regression] stress-ng udp-flood causes kernel panic on Ampere Altra #forregzbot Thorsten Leemhuis
2022-07-01 20:01 ` [Regression] stress-ng udp-flood causes kernel panic on Ampere Altra Florian Westphal
2022-07-02 11:08 ` Kajetan Puchalski
2022-07-02 11:54 ` Willy Tarreau
2022-07-02 20:56 ` Florian Westphal
2022-07-04 9:22 ` Kajetan Puchalski
2022-07-04 10:53 ` Kajetan Puchalski
2022-07-05 10:53 ` Kajetan Puchalski
2022-07-05 10:57 ` Will Deacon
2022-07-05 11:07 ` Will Deacon
2022-07-05 11:24 ` Will Deacon
2022-07-05 15:29 ` Kajetan Puchalski
2022-07-06 10:39 ` Kajetan Puchalski
2022-07-06 12:02 ` Florian Westphal
2022-07-06 12:18 ` Peter Zijlstra
2022-07-06 12:22 ` Will Deacon
2022-07-06 12:40 ` Florian Westphal
2022-07-06 14:50 ` [PATCH nf v3] netfilter: conntrack: fix crash due to confirmed bit load reordering Florian Westphal
2022-07-07 8:19 ` Will Deacon
2022-07-07 18:59 ` Florian Westphal
2022-07-07 10:17 ` Thorsten Leemhuis
2022-07-11 16:34 ` Kajetan Puchalski
2022-07-06 14:00 ` Peter Zijlstra [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=YsWVmrMA6aFE8oDr@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=broonie@kernel.org \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=dietmar.eggemann@arm.com \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=kadlec@netfilter.org \
--cc=kajetan.puchalski@arm.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=mark.rutland@arm.com \
--cc=mgorman@suse.de \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=regressions@lists.linux.dev \
--cc=stable@vger.kernel.org \
--cc=will@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).