netfilter: nftables: disallow updates on table ownership
authorPablo Neira Ayuso <pablo@netfilter.org>
Sat, 27 Feb 2021 21:31:27 +0000 (22:31 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 2 Mar 2021 15:37:22 +0000 (16:37 +0100)
Disallow updating the ownership bit on an existing table: Do not allow
to grab ownership on an existing table. Do not allow to drop ownership
on an existing table.

Fixes: 6001a930ce03 ("netfilter: nftables: introduce table ownership")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_tables_api.c

index c1eb5cdb30330f5fdb1b3d58e10f87db6bf83ac7..b07703e191080eccf10d0756d9cd0e30b06db223 100644 (file)
@@ -916,6 +916,12 @@ static int nf_tables_updtable(struct nft_ctx *ctx)
        if (flags == ctx->table->flags)
                return 0;
 
+       if ((nft_table_has_owner(ctx->table) &&
+            !(flags & NFT_TABLE_F_OWNER)) ||
+           (!nft_table_has_owner(ctx->table) &&
+            flags & NFT_TABLE_F_OWNER))
+               return -EOPNOTSUPP;
+
        trans = nft_trans_alloc(ctx, NFT_MSG_NEWTABLE,
                                sizeof(struct nft_trans_table));
        if (trans == NULL)