Commit aaba7ddc authored by Pablo Neira Ayuso's avatar Pablo Neira Ayuso

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: 96518518 ("netfilter: add nftables")
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent eff3c558
...@@ -2261,8 +2261,17 @@ static int nft_chain_parse_hook(struct net *net, ...@@ -2261,8 +2261,17 @@ static int nft_chain_parse_hook(struct net *net,
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
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; type = basechain->type;
} }
}
if (!try_module_get(type->owner)) { if (!try_module_get(type->owner)) {
if (nla[NFTA_CHAIN_TYPE]) if (nla[NFTA_CHAIN_TYPE])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment