mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
netfilter: nf_tables: hit ENOENT on unexisting chain/flowtable update with missing attributes
[ Upstream commit8509f62b0b] If user does not specify hook number and priority, then assume this is a chain/flowtable update. Therefore, report ENOENT which provides a better hint than EINVAL. Set on extended netlink error report to refer to the chain name. Fixes:5b6743fb2c("netfilter: nf_tables: skip flowtable hooknum and priority on device updates") Fixes: 5efe72698a97 ("netfilter: nf_tables: support for adding new devices to an existing netdev chain") Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
d8ed4a3f8b
commit
97b94e4a1d
@@ -2053,8 +2053,10 @@ static int nft_chain_parse_hook(struct net *net,
|
|||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (ha[NFTA_HOOK_HOOKNUM] == NULL ||
|
if (ha[NFTA_HOOK_HOOKNUM] == NULL ||
|
||||||
ha[NFTA_HOOK_PRIORITY] == NULL)
|
ha[NFTA_HOOK_PRIORITY] == NULL) {
|
||||||
return -EINVAL;
|
NL_SET_BAD_ATTR(extack, nla[NFTA_CHAIN_NAME]);
|
||||||
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
|
||||||
hook->num = ntohl(nla_get_be32(ha[NFTA_HOOK_HOOKNUM]));
|
hook->num = ntohl(nla_get_be32(ha[NFTA_HOOK_HOOKNUM]));
|
||||||
hook->priority = ntohl(nla_get_be32(ha[NFTA_HOOK_PRIORITY]));
|
hook->priority = ntohl(nla_get_be32(ha[NFTA_HOOK_PRIORITY]));
|
||||||
@@ -7556,7 +7558,7 @@ static const struct nla_policy nft_flowtable_hook_policy[NFTA_FLOWTABLE_HOOK_MAX
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int nft_flowtable_parse_hook(const struct nft_ctx *ctx,
|
static int nft_flowtable_parse_hook(const struct nft_ctx *ctx,
|
||||||
const struct nlattr *attr,
|
const struct nlattr * const nla[],
|
||||||
struct nft_flowtable_hook *flowtable_hook,
|
struct nft_flowtable_hook *flowtable_hook,
|
||||||
struct nft_flowtable *flowtable,
|
struct nft_flowtable *flowtable,
|
||||||
struct netlink_ext_ack *extack, bool add)
|
struct netlink_ext_ack *extack, bool add)
|
||||||
@@ -7568,15 +7570,18 @@ static int nft_flowtable_parse_hook(const struct nft_ctx *ctx,
|
|||||||
|
|
||||||
INIT_LIST_HEAD(&flowtable_hook->list);
|
INIT_LIST_HEAD(&flowtable_hook->list);
|
||||||
|
|
||||||
err = nla_parse_nested_deprecated(tb, NFTA_FLOWTABLE_HOOK_MAX, attr,
|
err = nla_parse_nested_deprecated(tb, NFTA_FLOWTABLE_HOOK_MAX,
|
||||||
|
nla[NFTA_FLOWTABLE_HOOK],
|
||||||
nft_flowtable_hook_policy, NULL);
|
nft_flowtable_hook_policy, NULL);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (add) {
|
if (add) {
|
||||||
if (!tb[NFTA_FLOWTABLE_HOOK_NUM] ||
|
if (!tb[NFTA_FLOWTABLE_HOOK_NUM] ||
|
||||||
!tb[NFTA_FLOWTABLE_HOOK_PRIORITY])
|
!tb[NFTA_FLOWTABLE_HOOK_PRIORITY]) {
|
||||||
return -EINVAL;
|
NL_SET_BAD_ATTR(extack, nla[NFTA_FLOWTABLE_NAME]);
|
||||||
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
|
||||||
hooknum = ntohl(nla_get_be32(tb[NFTA_FLOWTABLE_HOOK_NUM]));
|
hooknum = ntohl(nla_get_be32(tb[NFTA_FLOWTABLE_HOOK_NUM]));
|
||||||
if (hooknum != NF_NETDEV_INGRESS)
|
if (hooknum != NF_NETDEV_INGRESS)
|
||||||
@@ -7761,8 +7766,8 @@ static int nft_flowtable_update(struct nft_ctx *ctx, const struct nlmsghdr *nlh,
|
|||||||
u32 flags;
|
u32 flags;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = nft_flowtable_parse_hook(ctx, nla[NFTA_FLOWTABLE_HOOK],
|
err = nft_flowtable_parse_hook(ctx, nla, &flowtable_hook, flowtable,
|
||||||
&flowtable_hook, flowtable, extack, false);
|
extack, false);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
@@ -7907,8 +7912,8 @@ static int nf_tables_newflowtable(struct sk_buff *skb,
|
|||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto err3;
|
goto err3;
|
||||||
|
|
||||||
err = nft_flowtable_parse_hook(&ctx, nla[NFTA_FLOWTABLE_HOOK],
|
err = nft_flowtable_parse_hook(&ctx, nla, &flowtable_hook, flowtable,
|
||||||
&flowtable_hook, flowtable, extack, true);
|
extack, true);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto err4;
|
goto err4;
|
||||||
|
|
||||||
@@ -7970,8 +7975,8 @@ static int nft_delflowtable_hook(struct nft_ctx *ctx,
|
|||||||
struct nft_trans *trans;
|
struct nft_trans *trans;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = nft_flowtable_parse_hook(ctx, nla[NFTA_FLOWTABLE_HOOK],
|
err = nft_flowtable_parse_hook(ctx, nla, &flowtable_hook, flowtable,
|
||||||
&flowtable_hook, flowtable, extack, false);
|
extack, false);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user