Skip to content

Commit 9b39f75

Browse files
committed
Florian Westphal says: ==================== Netfilter fixes for net: The following patchset contains Netfilter fixes for net: 1. Fix spurious -EEXIST error from userspace due to padding holes, this was broken since 4.9 days when 'ignore duplicate entries on insert' feature was added. 2. Fix a sched-while-atomic bug, present since 5.19. 3. Properly remove elements if they lack an "end range". nft userspace always sets an end range attribute, even when its the same as the start, but the abi doesn't have such a restriction. Always broken since it was added in 5.6, all three from myself. 4 + 5: Bound chain needs to be skipped in netns release and on rule flush paths, from Pablo Neira. * tag 'nf-23-07-20' of https://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf: netfilter: nf_tables: skip bound chain on rule flush netfilter: nf_tables: skip bound chain in netns release path netfilter: nft_set_pipapo: fix improper element removal netfilter: nf_tables: can't schedule in nft_chain_validate netfilter: nf_tables: fix spurious set element insertion failure ==================== Link: https://lore.kernel.org/r/20230720165143.30208-1-fw@strlen.de Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 1c613be + 6eaf41e commit 9b39f75

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3685,8 +3685,6 @@ int nft_chain_validate(const struct nft_ctx *ctx, const struct nft_chain *chain)
36853685
if (err < 0)
36863686
return err;
36873687
}
3688-
3689-
cond_resched();
36903688
}
36913689

36923690
return 0;
@@ -3710,6 +3708,8 @@ static int nft_table_validate(struct net *net, const struct nft_table *table)
37103708
err = nft_chain_validate(&ctx, chain);
37113709
if (err < 0)
37123710
return err;
3711+
3712+
cond_resched();
37133713
}
37143714

37153715
return 0;
@@ -4087,6 +4087,8 @@ static int nf_tables_delrule(struct sk_buff *skb, const struct nfnl_info *info,
40874087
list_for_each_entry(chain, &table->chains, list) {
40884088
if (!nft_is_active_next(net, chain))
40894089
continue;
4090+
if (nft_chain_is_bound(chain))
4091+
continue;
40904092

40914093
ctx.chain = chain;
40924094
err = nft_delrule_by_chain(&ctx);
@@ -10517,6 +10519,9 @@ static int nft_verdict_init(const struct nft_ctx *ctx, struct nft_data *data,
1051710519

1051810520
if (!tb[NFTA_VERDICT_CODE])
1051910521
return -EINVAL;
10522+
10523+
/* zero padding hole for memcmp */
10524+
memset(data, 0, sizeof(*data));
1052010525
data->verdict.code = ntohl(nla_get_be32(tb[NFTA_VERDICT_CODE]));
1052110526

1052210527
switch (data->verdict.code) {
@@ -10799,6 +10804,9 @@ static void __nft_release_table(struct net *net, struct nft_table *table)
1079910804
ctx.family = table->family;
1080010805
ctx.table = table;
1080110806
list_for_each_entry(chain, &table->chains, list) {
10807+
if (nft_chain_is_bound(chain))
10808+
continue;
10809+
1080210810
ctx.chain = chain;
1080310811
list_for_each_entry_safe(rule, nr, &chain->rules, list) {
1080410812
list_del(&rule->list);

net/netfilter/nft_set_pipapo.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1929,7 +1929,11 @@ static void nft_pipapo_remove(const struct net *net, const struct nft_set *set,
19291929
int i, start, rules_fx;
19301930

19311931
match_start = data;
1932-
match_end = (const u8 *)nft_set_ext_key_end(&e->ext)->data;
1932+
1933+
if (nft_set_ext_exists(&e->ext, NFT_SET_EXT_KEY_END))
1934+
match_end = (const u8 *)nft_set_ext_key_end(&e->ext)->data;
1935+
else
1936+
match_end = data;
19331937

19341938
start = first_rule;
19351939
rules_fx = rules_f0;

0 commit comments

Comments
 (0)