Skip to content

Commit a16909a

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: nft_set_pipapo_avx2: disable softinterrupts
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: f0b3d33 ("netfilter: nft_set_pipapo_avx2: Add irq_fpu_usable() check, fallback to non-AVX2 version") Cc: Stefano Brivio <[email protected]> Signed-off-by: Florian Westphal <[email protected]> Reviewed-by: Stefano Brivio <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 3ba359c commit a16909a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

net/netfilter/nft_set_pipapo_avx2.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,8 +1139,14 @@ bool nft_pipapo_avx2_lookup(const struct net *net, const struct nft_set *set,
11391139
bool map_index;
11401140
int i, ret = 0;
11411141

1142-
if (unlikely(!irq_fpu_usable()))
1143-
return nft_pipapo_lookup(net, set, key, ext);
1142+
local_bh_disable();
1143+
1144+
if (unlikely(!irq_fpu_usable())) {
1145+
bool fallback_res = nft_pipapo_lookup(net, set, key, ext);
1146+
1147+
local_bh_enable();
1148+
return fallback_res;
1149+
}
11441150

11451151
m = rcu_dereference(priv->match);
11461152

@@ -1155,6 +1161,7 @@ bool nft_pipapo_avx2_lookup(const struct net *net, const struct nft_set *set,
11551161
scratch = *raw_cpu_ptr(m->scratch);
11561162
if (unlikely(!scratch)) {
11571163
kernel_fpu_end();
1164+
local_bh_enable();
11581165
return false;
11591166
}
11601167

@@ -1235,6 +1242,7 @@ bool nft_pipapo_avx2_lookup(const struct net *net, const struct nft_set *set,
12351242
if (i % 2)
12361243
scratch->map_index = !map_index;
12371244
kernel_fpu_end();
1245+
local_bh_enable();
12381246

12391247
return ret >= 0;
12401248
}

0 commit comments

Comments
 (0)