From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E42518801A; Tue, 30 Jul 2024 16:58:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722358685; cv=none; b=c29hXE0IToPTWPfHpa3KGCz0C8wzo/wTSMAb/yeW8H2DXKxJ4mHFXeav+lq1memRPhzATj/czMtRD9+BWi6e8JPiAX5/OgP4zuiqhzGwX90OZLDleD6o3XUpF1l+icttRR20YPB6DqR7xYyBjr3UL9/I3AyILoujrX5kUDbUXvs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722358685; c=relaxed/simple; bh=+oHxzLGRHKtpxeEvQOT+hUvGXXytDM+aZ5uJifQG8YU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VIF2llETagR3Nf8jcEpKyHdOtven+AWapJBRuIwMCgv9Jio1owik25Avz0uSrju6xJNRtkTFoe87MI6PrP90qCNiKVA1msLfA6fwqA/AMSiVE5pmjpKYZETf+c18dzFTwYY+LnTNEh2JPXnw+2zXrP6lQZY+oLC2ZYRMqZsYimA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=v5ZFGM/A; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="v5ZFGM/A" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACFFEC4AF0A; Tue, 30 Jul 2024 16:58:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1722358685; bh=+oHxzLGRHKtpxeEvQOT+hUvGXXytDM+aZ5uJifQG8YU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v5ZFGM/AJ0vXPg4iBxUT3u5MEriXYLc0mqoV2+YApUW0W5msK8C6XWpopy3iaBt9X XaLGNgz/hZSDVyRXvTCX4Wzjd1TKVQL9wv5QkWoZ375jLIphRsReG/Q8ryXkEPaHv3 sh3k+WnOsI1jeTZO1ElNdtuWj9fSMPVqi121NIew= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Stefano Brivio , Florian Westphal , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 6.1 413/440] netfilter: nft_set_pipapo_avx2: disable softinterrupts Date: Tue, 30 Jul 2024 17:50:46 +0200 Message-ID: <20240730151631.922669378@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240730151615.753688326@linuxfoundation.org> References: <20240730151615.753688326@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Florian Westphal [ Upstream commit a16909ae9982e931841c456061cb57fbaec9c59e ] We need to disable softinterrupts, else we get following problem: 1. pipapo_avx2 called from process context; fpu usable 2. preempt_disable() called, pcpu scratchmap in use 3. softirq handles rx or tx, we re-enter pipapo_avx2 4. fpu busy, fallback to generic non-avx version 5. fallback reuses scratch map and index, which are in use by the preempted process Handle this same way as generic version by first disabling softinterrupts while the scratchmap is in use. Fixes: f0b3d338064e ("netfilter: nft_set_pipapo_avx2: Add irq_fpu_usable() check, fallback to non-AVX2 version") Cc: Stefano Brivio Signed-off-by: Florian Westphal Reviewed-by: Stefano Brivio Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nft_set_pipapo_avx2.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/net/netfilter/nft_set_pipapo_avx2.c b/net/netfilter/nft_set_pipapo_avx2.c index 8910a5ac7ed12..b8d3c3213efee 100644 --- a/net/netfilter/nft_set_pipapo_avx2.c +++ b/net/netfilter/nft_set_pipapo_avx2.c @@ -1139,8 +1139,14 @@ bool nft_pipapo_avx2_lookup(const struct net *net, const struct nft_set *set, bool map_index; int i, ret = 0; - if (unlikely(!irq_fpu_usable())) - return nft_pipapo_lookup(net, set, key, ext); + local_bh_disable(); + + if (unlikely(!irq_fpu_usable())) { + bool fallback_res = nft_pipapo_lookup(net, set, key, ext); + + local_bh_enable(); + return fallback_res; + } m = rcu_dereference(priv->match); @@ -1155,6 +1161,7 @@ bool nft_pipapo_avx2_lookup(const struct net *net, const struct nft_set *set, scratch = *raw_cpu_ptr(m->scratch); if (unlikely(!scratch)) { kernel_fpu_end(); + local_bh_enable(); return false; } @@ -1235,6 +1242,7 @@ bool nft_pipapo_avx2_lookup(const struct net *net, const struct nft_set *set, if (i % 2) scratch->map_index = !map_index; kernel_fpu_end(); + local_bh_enable(); return ret >= 0; } -- 2.43.0