Skip to content

Commit 4c34625

Browse files
Florian Westphalgregkh
authored andcommitted
netfilter: nf_tables: make nft_set_do_lookup available unconditionally
[ Upstream commit 11fe5a8 ] This function was added for retpoline mitigation and is replaced by a static inline helper if mitigations are not enabled. Enable this helper function unconditionally so next patch can add a lookup restart mechanism to fix possible false negatives while transactions are in progress. Adding lookup restarts in nft_lookup_eval doesn't work as nft_objref would then need the same copypaste loop. This patch is separate to ease review of the actual bug fix. Suggested-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Florian Westphal <fw@strlen.de> Stable-dep-of: b2f742c ("netfilter: nf_tables: restart set lookup on base_seq change") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 259c4e8 commit 4c34625

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

include/net/netfilter/nf_tables_core.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,11 @@ nft_hash_lookup_fast(const struct net *net, const struct nft_set *set,
109109
const struct nft_set_ext *
110110
nft_hash_lookup(const struct net *net, const struct nft_set *set,
111111
const u32 *key);
112+
#endif
113+
112114
const struct nft_set_ext *
113115
nft_set_do_lookup(const struct net *net, const struct nft_set *set,
114116
const u32 *key);
115-
#else
116-
static inline const struct nft_set_ext *
117-
nft_set_do_lookup(const struct net *net, const struct nft_set *set,
118-
const u32 *key)
119-
{
120-
return set->ops->lookup(net, set, key);
121-
}
122-
#endif
123117

124118
/* called from nft_pipapo_avx2.c */
125119
const struct nft_set_ext *

net/netfilter/nft_lookup.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ struct nft_lookup {
2424
struct nft_set_binding binding;
2525
};
2626

27-
#ifdef CONFIG_MITIGATION_RETPOLINE
28-
const struct nft_set_ext *
29-
nft_set_do_lookup(const struct net *net, const struct nft_set *set,
30-
const u32 *key)
27+
static const struct nft_set_ext *
28+
__nft_set_do_lookup(const struct net *net, const struct nft_set *set,
29+
const u32 *key)
3130
{
31+
#ifdef CONFIG_MITIGATION_RETPOLINE
3232
if (set->ops == &nft_set_hash_fast_type.ops)
3333
return nft_hash_lookup_fast(net, set, key);
3434
if (set->ops == &nft_set_hash_type.ops)
@@ -51,10 +51,17 @@ nft_set_do_lookup(const struct net *net, const struct nft_set *set,
5151
return nft_rbtree_lookup(net, set, key);
5252

5353
WARN_ON_ONCE(1);
54+
#endif
5455
return set->ops->lookup(net, set, key);
5556
}
57+
58+
const struct nft_set_ext *
59+
nft_set_do_lookup(const struct net *net, const struct nft_set *set,
60+
const u32 *key)
61+
{
62+
return __nft_set_do_lookup(net, set, key);
63+
}
5664
EXPORT_SYMBOL_GPL(nft_set_do_lookup);
57-
#endif
5865

5966
void nft_lookup_eval(const struct nft_expr *expr,
6067
struct nft_regs *regs,

0 commit comments

Comments
 (0)