diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2023-12-14 22:43:22 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2023-12-22 12:15:28 +0100 |
commit | aaba7ddc8507f4ad5bbd07988573967632bc2385 (patch) | |
tree | 384dea5a798a45ae77aeb78c924558b3dd7a4a09 /net/netfilter | |
parent | eff3c558bb7e61c41b53e4c8130e514a5a4df9ba (diff) | |
download | linux-stable-aaba7ddc8507f4ad5bbd07988573967632bc2385.tar.gz linux-stable-aaba7ddc8507f4ad5bbd07988573967632bc2385.tar.bz2 linux-stable-aaba7ddc8507f4ad5bbd07988573967632bc2385.zip |
netfilter: nf_tables: validate chain type update if available
Parse netlink attribute containing the chain type in this update, to
bail out if this is different from the existing type.
Otherwise, it is possible to define a chain with the same name, hook and
priority but different type, which is silently ignored.
Fixes: 96518518cc41 ("netfilter: add nftables")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net/netfilter')
-rw-r--r-- | net/netfilter/nf_tables_api.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 4c3de1a2c52b..5531b13d92b6 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -2261,7 +2261,16 @@ static int nft_chain_parse_hook(struct net *net, return -EOPNOTSUPP; } - type = basechain->type; + if (nla[NFTA_CHAIN_TYPE]) { + type = __nf_tables_chain_type_lookup(nla[NFTA_CHAIN_TYPE], + family); + if (!type) { + NL_SET_BAD_ATTR(extack, nla[NFTA_CHAIN_TYPE]); + return -ENOENT; + } + } else { + type = basechain->type; + } } if (!try_module_get(type->owner)) { |