Skip to content

Commit 35d45e9

Browse files
committed
netfilter: nf_tables: disallow element removal on anonymous sets
jira VULN-597 subsystem-sync netfilter:nf_tables 4.18.0-534 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 50e218d commit 35d45e9

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);
@@ -5921,8 +5920,10 @@ static int nf_tables_delsetelem(struct net *net, struct sock *nlsk,
59215920
if (IS_ERR(set))
59225921
return PTR_ERR(set);
59235922

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

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

0 commit comments

Comments
 (0)