Skip to content

Commit 1f63a37

Browse files
committed
netfilter: nf_tables: disallow element removal on anonymous sets
jira VUlN-597 subsystem-sync netfilter:nf_tables 4.18.0-511 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: Greg Rose <g.v.rose@ciq.com>
1 parent 8122af3 commit 1f63a37

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
@@ -1139,8 +1139,7 @@ static int nft_flush_table(struct nft_ctx *ctx)
11391139
if (!nft_is_active_next(ctx->net, set))
11401140
continue;
11411141

1142-
if (nft_set_is_anonymous(set) &&
1143-
!list_empty(&set->bindings))
1142+
if (nft_set_is_anonymous(set))
11441143
continue;
11451144

11461145
err = nft_delset(ctx, set);
@@ -5922,8 +5921,10 @@ static int nf_tables_delsetelem(struct net *net, struct sock *nlsk,
59225921
if (IS_ERR(set))
59235922
return PTR_ERR(set);
59245923

5925-
if (!list_empty(&set->bindings) &&
5926-
(set->flags & (NFT_SET_CONSTANT | NFT_SET_ANONYMOUS)))
5924+
if (nft_set_is_anonymous(set))
5925+
return -EOPNOTSUPP;
5926+
5927+
if (!list_empty(&set->bindings) && (set->flags & NFT_SET_CONSTANT))
59275928
return -EBUSY;
59285929

59295930
if (nla[NFTA_SET_ELEM_LIST_ELEMENTS] == NULL) {

0 commit comments

Comments
 (0)