Skip to content

Commit aaba7dd

Browse files
committed
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: 9651851 ("netfilter: add nftables") Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent eff3c55 commit aaba7dd

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2261,7 +2261,16 @@ static int nft_chain_parse_hook(struct net *net,
22612261
return -EOPNOTSUPP;
22622262
}
22632263

2264-
type = basechain->type;
2264+
if (nla[NFTA_CHAIN_TYPE]) {
2265+
type = __nf_tables_chain_type_lookup(nla[NFTA_CHAIN_TYPE],
2266+
family);
2267+
if (!type) {
2268+
NL_SET_BAD_ATTR(extack, nla[NFTA_CHAIN_TYPE]);
2269+
return -ENOENT;
2270+
}
2271+
} else {
2272+
type = basechain->type;
2273+
}
22652274
}
22662275

22672276
if (!try_module_get(type->owner)) {

0 commit comments

Comments
 (0)