Skip to content

Commit 80b9442

Browse files
committed
netfilter: nf_tables: disallow element removal on anonymous sets
jira VULN-430 cve CVE-2023-4244 commit-author Pablo Neira Ayuso <pablo@netfilter.org> commit 23a3bfd Anonymous sets need to be populated once at creation and then they are bound to rule since 938154b ("netfilter: nf_tables: reject unbound anonymous set before commit phase"), otherwise transaction reports EINVAL. Userspace does not need to delete elements of anonymous sets that are not yet bound, reject this with EOPNOTSUPP. From flush command path, skip anonymous sets, they are expected to be bound already. Otherwise, EINVAL is hit at the end of this transaction for unbound sets. Fixes: 9651851 ("netfilter: add nftables") Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> (cherry picked from commit 23a3bfd) Signed-off-by: Marcin Wcisło <marcin.wcislo@conclusive.pl>
1 parent b5c6baa commit 80b9442

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,8 +1385,7 @@ static int nft_flush_table(struct nft_ctx *ctx)
13851385
if (!nft_is_active_next(ctx->net, set))
13861386
continue;
13871387

1388-
if (nft_set_is_anonymous(set) &&
1389-
!list_empty(&set->bindings))
1388+
if (nft_set_is_anonymous(set))
13901389
continue;
13911390

13921391
err = nft_delset(ctx, set);
@@ -6909,8 +6908,10 @@ static int nf_tables_delsetelem(struct sk_buff *skb,
69096908
if (IS_ERR(set))
69106909
return PTR_ERR(set);
69116910

6912-
if (!list_empty(&set->bindings) &&
6913-
(set->flags & (NFT_SET_CONSTANT | NFT_SET_ANONYMOUS)))
6911+
if (nft_set_is_anonymous(set))
6912+
return -EOPNOTSUPP;
6913+
6914+
if (!list_empty(&set->bindings) && (set->flags & NFT_SET_CONSTANT))
69146915
return -EBUSY;
69156916

69166917
nft_ctx_init(&ctx, net, skb, info->nlh, family, table, NULL, nla);

0 commit comments

Comments
 (0)