Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2502738imw; Wed, 6 Jul 2022 07:04:24 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sFzvG0THGyF/UKdZD0F1RjEdamTfwSUqB3z0vzemSQ0x+b6kGGb2rxQGdsMRld6Xbw760Z X-Received: by 2002:a17:907:b06:b0:72a:faf3:3e05 with SMTP id h6-20020a1709070b0600b0072afaf33e05mr2939377ejl.124.1657116264562; Wed, 06 Jul 2022 07:04:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657116264; cv=none; d=google.com; s=arc-20160816; b=tn8KZVXPzAMHD32QPZIR4DQK0nmaR82QwOwKvRKrZ5rlgfxLdW7EFQKJ5YYA//XM5v YEWriNQdhl8NWbmArpT7IM2sQVPIUWaJ+87z+26ZuaZpsi1LoIgt3HSHwWy7gQkpz5EQ t40lQVlJz1p28iDIs7xuSiLdMHsndSXxh70ECoaBo/tchJghrw0QcEqhdQDNlVe1lw37 mTYVAGLoU63Ux+a7Jt79DDGoqGJWuYeZbIYAgRbtf1NEE0rXVfWH5yu6CeYVGGwx6KDx j4vu8uOjDDr+VTOW5zZZcv/z0A7i1ms3ktSN8J1vnDOzJJBpsPDj2i61ybDbEEzzl7G2 eHEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ouRvW6OEP3qkY26xFcBJ9tiIR5hvG8wwzWSrM+uEL/I=; b=vUOM9w4r9eVl27IAoOC7+0mNIeT3MwuRJ9a1akFHKsltDZnlXPZm5EdUForovd/bNX JSpfQXKzEOtIuW9a3t5NfEdyzMHV/bgxyAk9ZwDheBG63qwqL3cajG8ys4XfA/D/Whhi X3wkRbOxXWlQ54a+oc8CByIGtCkyoJSic4Fz6L4KgPZuEF1luy/CwIKecjLXsHOXvyAz YcUykhpLf0yUVsNOIGiuGdI4gOEKMASnv46ZahtCcd3HF41k4LykPKsA1ZmEV6+QHgyA ffIzWFI4wfPZ/3Bv7ndajGuvYkbEaKpZkLw6/k7oPokOClUxYU4E+hmnBtUyXQClUjt/ mXiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=r22GQMcj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ej27-20020a056402369b00b00437749846e0si19465700edb.574.2022.07.06.07.03.58; Wed, 06 Jul 2022 07:04:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=r22GQMcj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233637AbiGFOBf (ORCPT + 99 others); Wed, 6 Jul 2022 10:01:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233210AbiGFOBY (ORCPT ); Wed, 6 Jul 2022 10:01:24 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58E371AF0E; Wed, 6 Jul 2022 07:01:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=ouRvW6OEP3qkY26xFcBJ9tiIR5hvG8wwzWSrM+uEL/I=; b=r22GQMcjL2cTA+cmoNxVKQaYIQ dwhyEH3B7jMmYNkgOavl/Jkw8ahF4pUqGA50knBcMnA+T7sUrrZ34FNLk4CpwNXFlmdCBQuXuMgC6 AwUQVVNBvUsYsvtg7SJXC+mM8yy+m6Yfn9zYum2In+mCHyjoDJoEwkrrZFDQZ6zu2qEi08X4EGXjG nqFhc+W39vckzfBqTLqNhD57KglAOvtgqwC9xCwGrEpzefP77PX2X4XR0rU0k/TUHqxUt8Hfpbgu0 VA0+lOt3y9ds9A8wP/CLThg+mPx0CMIJgQ3BWj69BlplgxU6U7cObaHqud6BY2yAxc6mtQbeVyZWS MeY41few==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1o95aN-001hHB-5i; Wed, 06 Jul 2022 14:00:59 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 727A9300779; Wed, 6 Jul 2022 16:00:58 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 53F5E201E7FAD; Wed, 6 Jul 2022 16:00:58 +0200 (CEST) Date: Wed, 6 Jul 2022 16:00:58 +0200 From: Peter Zijlstra To: Will Deacon Cc: Florian Westphal , Kajetan Puchalski , Pablo Neira Ayuso , Jozsef Kadlecsik , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mel Gorman , 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 Message-ID: References: <20220702205651.GB15144@breakpoint.cc> <20220705105749.GA711@willie-the-truck> <20220705110724.GB711@willie-the-truck> <20220705112449.GA931@willie-the-truck> <20220706120201.GA7996@breakpoint.cc> <20220706122246.GI2403@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220706122246.GI2403@willie-the-truck> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.