netfilter: nft_compat: restrict match/target protocol to u16
xt_check_{match,target} expects u16, but NFTA_RULE_COMPAT_PROTO is u32. NLA_POLICY_MAX(NLA_BE32, 65535) cannot be used because .max in nla_policy is s16, see3e48be05f3
("netlink: add attribute range validation to policy"). Fixes:0ca743a559
("netfilter: nf_tables: add compatibility layer for x_tables") Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
parent
292781c3c5
commit
d694b75489
1 changed files with 7 additions and 1 deletions
|
@ -200,6 +200,7 @@ static const struct nla_policy nft_rule_compat_policy[NFTA_RULE_COMPAT_MAX + 1]
|
||||||
static int nft_parse_compat(const struct nlattr *attr, u16 *proto, bool *inv)
|
static int nft_parse_compat(const struct nlattr *attr, u16 *proto, bool *inv)
|
||||||
{
|
{
|
||||||
struct nlattr *tb[NFTA_RULE_COMPAT_MAX+1];
|
struct nlattr *tb[NFTA_RULE_COMPAT_MAX+1];
|
||||||
|
u32 l4proto;
|
||||||
u32 flags;
|
u32 flags;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
@ -218,7 +219,12 @@ static int nft_parse_compat(const struct nlattr *attr, u16 *proto, bool *inv)
|
||||||
if (flags & NFT_RULE_COMPAT_F_INV)
|
if (flags & NFT_RULE_COMPAT_F_INV)
|
||||||
*inv = true;
|
*inv = true;
|
||||||
|
|
||||||
*proto = ntohl(nla_get_be32(tb[NFTA_RULE_COMPAT_PROTO]));
|
l4proto = ntohl(nla_get_be32(tb[NFTA_RULE_COMPAT_PROTO]));
|
||||||
|
if (l4proto > U16_MAX)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
*proto = l4proto;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue