netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Arturo Borrero Gonzalez <arturo@netfilter.org>
Cc: "netfilter-devel@vger.kernel.org"
	<netfilter-devel@vger.kernel.org>,
	Stefano Brivio <sbrivio@redhat.com>
Subject: Re: nft_pipapo_avx2_lookup backtrace in linux 5.10
Date: Fri, 7 May 2021 12:35:23 +0200	[thread overview]
Message-ID: <20210507103523.GA19649@breakpoint.cc> (raw)
In-Reply-To: <8ff71ad7-7171-c8c7-f31b-d4bd7577cc18@netfilter.org>

Arturo Borrero Gonzalez <arturo@netfilter.org> wrote:
> Hi there,
> 
> I got this backtrace in one of my servers. I wonder if it is known or fixed
> already in a later version.
> 
> My versions:
> * kernel 5.10.24
> * nft 0.9.6
> 
> Also, find attached the ruleset that triggered this.
> 
> [Thu May  6 16:20:21 2021] ------------[ cut here ]------------
> [Thu May  6 16:20:21 2021] WARNING: CPU: 3 PID: 456 at
> arch/x86/kernel/fpu/core.c:129 kernel_fpu_begin_mask+0xc9/0xe0
> [Thu May  6 16:20:21 2021] Modules linked in: binfmt_misc nft_nat

Hmm, I suspect this is needed (not even compile tested).

diff --git a/net/netfilter/nft_set_pipapo_avx2.c b/net/netfilter/nft_set_pipapo_avx2.c
--- a/net/netfilter/nft_set_pipapo_avx2.c
+++ b/net/netfilter/nft_set_pipapo_avx2.c
@@ -1105,6 +1105,18 @@ bool nft_pipapo_avx2_estimate(const struct nft_set_desc *desc, u32 features,
 	return true;
 }
 
+static void nft_pipapo_avx_begin(void)
+{
+	local_bh_disable();
+	kernel_fpu_begin();
+}
+
+static void nft_pipapo_avx_end(void)
+{
+	kernel_fpu_end();
+	local_bh_enable();
+}
+
 /**
  * nft_pipapo_avx2_lookup() - Lookup function for AVX2 implementation
  * @net:	Network namespace
@@ -1134,11 +1146,11 @@ bool nft_pipapo_avx2_lookup(const struct net *net, const struct nft_set *set,
 	m = rcu_dereference(priv->match);
 
 	/* This also protects access to all data related to scratch maps */
-	kernel_fpu_begin();
+	nft_pipapo_avx_begin();
 
 	scratch = *raw_cpu_ptr(m->scratch_aligned);
 	if (unlikely(!scratch)) {
-		kernel_fpu_end();
+		nft_pipapo_avx_end();
 		return false;
 	}
 	map_index = raw_cpu_read(nft_pipapo_avx2_scratch_index);
@@ -1217,7 +1229,7 @@ bool nft_pipapo_avx2_lookup(const struct net *net, const struct nft_set *set,
 out:
 	if (i % 2)
 		raw_cpu_write(nft_pipapo_avx2_scratch_index, !map_index);
-	kernel_fpu_end();
+	nft_pipapo_avx_end();
 
 	return ret >= 0;
 }

kernel_fpu_begin() disables preemption, but we can still reenter via
softirq.

  reply	other threads:[~2021-05-07 10:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-07  9:26 nft_pipapo_avx2_lookup backtrace in linux 5.10 Arturo Borrero Gonzalez
2021-05-07 10:35 ` Florian Westphal [this message]
2021-05-07 10:52   ` Stefano Brivio
2021-05-08  1:00     ` Stefano Brivio
2021-05-09 11:00       ` Arturo Borrero Gonzalez
2021-05-07 10:36 ` Stefano Brivio
2021-05-07 11:12   ` Arturo Borrero Gonzalez
2021-05-08  1:00     ` Stefano Brivio
2021-05-09 10:58       ` Arturo Borrero Gonzalez

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=20210507103523.GA19649@breakpoint.cc \
    --to=fw@strlen.de \
    --cc=arturo@netfilter.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=sbrivio@redhat.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;
as well as URLs for NNTP newsgroup(s).