Skip to content

Commit c88c535

Browse files
committed
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 <[email protected]>
1 parent d6b4786 commit c88c535

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
@@ -6779,7 +6779,8 @@ static int nf_tables_newsetelem(struct sk_buff *skb,
67796779
if (IS_ERR(set))
67806780
return PTR_ERR(set);
67816781

6782-
if (!list_empty(&set->bindings) && set->flags & NFT_SET_CONSTANT)
6782+
if (!list_empty(&set->bindings) &&
6783+
(set->flags & (NFT_SET_CONSTANT | NFT_SET_ANONYMOUS)))
67836784
return -EBUSY;
67846785

67856786
nft_ctx_init(&ctx, net, skb, info->nlh, family, table, NULL, nla);
@@ -7053,7 +7054,9 @@ static int nf_tables_delsetelem(struct sk_buff *skb,
70537054
set = nft_set_lookup(table, nla[NFTA_SET_ELEM_LIST_SET], genmask);
70547055
if (IS_ERR(set))
70557056
return PTR_ERR(set);
7056-
if (!list_empty(&set->bindings) && set->flags & NFT_SET_CONSTANT)
7057+
7058+
if (!list_empty(&set->bindings) &&
7059+
(set->flags & (NFT_SET_CONSTANT | NFT_SET_ANONYMOUS)))
70577060
return -EBUSY;
70587061

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

0 commit comments

Comments
 (0)