netfilter: nf_tables: missing extended netlink error in lookup functions
Set netlink extended error reporting for several lookup functions which allows userspace to infer what is the error cause. Reported-by: Phil Sutter <phil@nwl.cc> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Florian Westphal <fw@strlen.de>
This commit is contained in:
parent
117e149e26
commit
aee1f692bf
@ -4695,8 +4695,10 @@ static int nf_tables_getset(struct sk_buff *skb, const struct nfnl_info *info,
|
||||
return -EINVAL;
|
||||
|
||||
set = nft_set_lookup(table, nla[NFTA_SET_NAME], genmask);
|
||||
if (IS_ERR(set))
|
||||
if (IS_ERR(set)) {
|
||||
NL_SET_BAD_ATTR(extack, nla[NFTA_SET_NAME]);
|
||||
return PTR_ERR(set);
|
||||
}
|
||||
|
||||
skb2 = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC);
|
||||
if (skb2 == NULL)
|
||||
@ -6025,8 +6027,10 @@ static int nf_tables_getsetelem(struct sk_buff *skb,
|
||||
}
|
||||
|
||||
set = nft_set_lookup(table, nla[NFTA_SET_ELEM_LIST_SET], genmask);
|
||||
if (IS_ERR(set))
|
||||
if (IS_ERR(set)) {
|
||||
NL_SET_BAD_ATTR(extack, nla[NFTA_SET_ELEM_LIST_SET]);
|
||||
return PTR_ERR(set);
|
||||
}
|
||||
|
||||
nft_ctx_init(&ctx, net, skb, info->nlh, family, table, NULL, nla);
|
||||
|
||||
@ -6919,8 +6923,10 @@ static int nf_tables_newsetelem(struct sk_buff *skb,
|
||||
|
||||
set = nft_set_lookup_global(net, table, nla[NFTA_SET_ELEM_LIST_SET],
|
||||
nla[NFTA_SET_ELEM_LIST_SET_ID], genmask);
|
||||
if (IS_ERR(set))
|
||||
if (IS_ERR(set)) {
|
||||
NL_SET_BAD_ATTR(extack, nla[NFTA_SET_ELEM_LIST_SET]);
|
||||
return PTR_ERR(set);
|
||||
}
|
||||
|
||||
if (!list_empty(&set->bindings) &&
|
||||
(set->flags & (NFT_SET_CONSTANT | NFT_SET_ANONYMOUS)))
|
||||
@ -7195,8 +7201,10 @@ static int nf_tables_delsetelem(struct sk_buff *skb,
|
||||
}
|
||||
|
||||
set = nft_set_lookup(table, nla[NFTA_SET_ELEM_LIST_SET], genmask);
|
||||
if (IS_ERR(set))
|
||||
if (IS_ERR(set)) {
|
||||
NL_SET_BAD_ATTR(extack, nla[NFTA_SET_ELEM_LIST_SET]);
|
||||
return PTR_ERR(set);
|
||||
}
|
||||
|
||||
if (nft_set_is_anonymous(set))
|
||||
return -EOPNOTSUPP;
|
||||
@ -8680,6 +8688,7 @@ static int nf_tables_getflowtable(struct sk_buff *skb,
|
||||
const struct nfnl_info *info,
|
||||
const struct nlattr * const nla[])
|
||||
{
|
||||
struct netlink_ext_ack *extack = info->extack;
|
||||
u8 genmask = nft_genmask_cur(info->net);
|
||||
u8 family = info->nfmsg->nfgen_family;
|
||||
struct nft_flowtable *flowtable;
|
||||
@ -8705,13 +8714,17 @@ static int nf_tables_getflowtable(struct sk_buff *skb,
|
||||
|
||||
table = nft_table_lookup(net, nla[NFTA_FLOWTABLE_TABLE], family,
|
||||
genmask, 0);
|
||||
if (IS_ERR(table))
|
||||
if (IS_ERR(table)) {
|
||||
NL_SET_BAD_ATTR(extack, nla[NFTA_FLOWTABLE_TABLE]);
|
||||
return PTR_ERR(table);
|
||||
}
|
||||
|
||||
flowtable = nft_flowtable_lookup(table, nla[NFTA_FLOWTABLE_NAME],
|
||||
genmask);
|
||||
if (IS_ERR(flowtable))
|
||||
if (IS_ERR(flowtable)) {
|
||||
NL_SET_BAD_ATTR(extack, nla[NFTA_FLOWTABLE_NAME]);
|
||||
return PTR_ERR(flowtable);
|
||||
}
|
||||
|
||||
skb2 = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC);
|
||||
if (!skb2)
|
||||
|
Loading…
x
Reference in New Issue
Block a user