Skip to content

Commit 59ae9e4

Browse files
committed
netfilter: nf_tables: disallow element removal on anonymous sets
JIRA: https://issues.redhat.com/browse/RHEL-1720 JIRA: https://issues.redhat.com/browse/RHEL-1721 Upstream Status: commit 23a3bfd commit 23a3bfd Author: Pablo Neira Ayuso <pablo@netfilter.org> Date: Sun Sep 10 19:04:45 2023 +0200 netfilter: nf_tables: disallow element removal on anonymous sets 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> Signed-off-by: Florian Westphal <fwestpha@redhat.com>
1 parent 465bbb2 commit 59ae9e4

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
@@ -1358,8 +1358,7 @@ static int nft_flush_table(struct nft_ctx *ctx)
13581358
if (!nft_is_active_next(ctx->net, set))
13591359
continue;
13601360

1361-
if (nft_set_is_anonymous(set) &&
1362-
!list_empty(&set->bindings))
1361+
if (nft_set_is_anonymous(set))
13631362
continue;
13641363

13651364
err = nft_delset(ctx, set);
@@ -6884,8 +6883,10 @@ static int nf_tables_delsetelem(struct sk_buff *skb,
68846883
if (IS_ERR(set))
68856884
return PTR_ERR(set);
68866885

6887-
if (!list_empty(&set->bindings) &&
6888-
(set->flags & (NFT_SET_CONSTANT | NFT_SET_ANONYMOUS)))
6886+
if (nft_set_is_anonymous(set))
6887+
return -EOPNOTSUPP;
6888+
6889+
if (!list_empty(&set->bindings) && (set->flags & NFT_SET_CONSTANT))
68896890
return -EBUSY;
68906891

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

0 commit comments

Comments
 (0)