Skip to content

Commit

Permalink
netfilter: nf_tables: reject unsupported chain flags
Browse files Browse the repository at this point in the history
Bail out if userspace sends unsupported chain flags.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Pablo Neira Ayuso committed Jul 4, 2020
1 parent d0e2c7d commit c1f79a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/uapi/linux/netfilter/nf_tables.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ enum nft_chain_flags {
NFT_CHAIN_HW_OFFLOAD = (1 << 1),
NFT_CHAIN_BINDING = (1 << 2),
};
#define NFT_CHAIN_FLAGS (NFT_CHAIN_BASE | \
NFT_CHAIN_HW_OFFLOAD | \
NFT_CHAIN_BINDING)

/**
* enum nft_chain_attributes - nf_tables chain netlink attributes
Expand Down
3 changes: 3 additions & 0 deletions net/netfilter/nf_tables_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -2285,6 +2285,9 @@ static int nf_tables_newchain(struct net *net, struct sock *nlsk,
else if (chain)
flags = chain->flags;

if (flags & ~NFT_CHAIN_FLAGS)
return -EOPNOTSUPP;

nft_ctx_init(&ctx, net, skb, nlh, family, table, chain, nla);

if (chain != NULL) {
Expand Down

0 comments on commit c1f79a2

Please sign in to comment.