Skip to content

Commit 23a3bfd

Browse files
committed
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>
1 parent b079155 commit 23a3bfd

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
@@ -1446,8 +1446,7 @@ static int nft_flush_table(struct nft_ctx *ctx)
14461446
if (!nft_is_active_next(ctx->net, set))
14471447
continue;
14481448

1449-
if (nft_set_is_anonymous(set) &&
1450-
!list_empty(&set->bindings))
1449+
if (nft_set_is_anonymous(set))
14511450
continue;
14521451

14531452
err = nft_delset(ctx, set);
@@ -7191,8 +7190,10 @@ static int nf_tables_delsetelem(struct sk_buff *skb,
71917190
if (IS_ERR(set))
71927191
return PTR_ERR(set);
71937192

7194-
if (!list_empty(&set->bindings) &&
7195-
(set->flags & (NFT_SET_CONSTANT | NFT_SET_ANONYMOUS)))
7193+
if (nft_set_is_anonymous(set))
7194+
return -EOPNOTSUPP;
7195+
7196+
if (!list_empty(&set->bindings) && (set->flags & NFT_SET_CONSTANT))
71967197
return -EBUSY;
71977198

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

0 commit comments

Comments
 (0)