Skip to content

Commit 46d60b5

Browse files
committed
netfilter: nf_tables: disallow element updates of bound anonymous sets
JIRA: https://issues.redhat.com/browse/RHEL-1720 JIRA: https://issues.redhat.com/browse/RHEL-1721 Upstream Status: commit c88c535 commit c88c535 Author: Pablo Neira Ayuso <pablo@netfilter.org> Date: Fri Jun 16 15:20:16 2023 +0200 netfilter: nf_tables: disallow element updates of bound anonymous sets Anonymous sets come with NFT_SET_CONSTANT from userspace. Although API allows to create anonymous sets without NFT_SET_CONSTANT, it makes no sense to allow to add and to delete elements for bound anonymous 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 3965620 commit 46d60b5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6554,7 +6554,8 @@ static int nf_tables_newsetelem(struct sk_buff *skb,
65546554
if (IS_ERR(set))
65556555
return PTR_ERR(set);
65566556

6557-
if (!list_empty(&set->bindings) && set->flags & NFT_SET_CONSTANT)
6557+
if (!list_empty(&set->bindings) &&
6558+
(set->flags & (NFT_SET_CONSTANT | NFT_SET_ANONYMOUS)))
65586559
return -EBUSY;
65596560

65606561
nft_ctx_init(&ctx, net, skb, info->nlh, family, table, NULL, nla);
@@ -6828,7 +6829,9 @@ static int nf_tables_delsetelem(struct sk_buff *skb,
68286829
set = nft_set_lookup(table, nla[NFTA_SET_ELEM_LIST_SET], genmask);
68296830
if (IS_ERR(set))
68306831
return PTR_ERR(set);
6831-
if (!list_empty(&set->bindings) && set->flags & NFT_SET_CONSTANT)
6832+
6833+
if (!list_empty(&set->bindings) &&
6834+
(set->flags & (NFT_SET_CONSTANT | NFT_SET_ANONYMOUS)))
68326835
return -EBUSY;
68336836

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

0 commit comments

Comments
 (0)