Commit aee1f692 authored by Pablo Neira Ayuso's avatar Pablo Neira Ayuso Committed by Florian Westphal

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: default avatarPhil Sutter <phil@nwl.cc>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
parent 117e149e
...@@ -4695,8 +4695,10 @@ static int nf_tables_getset(struct sk_buff *skb, const struct nfnl_info *info, ...@@ -4695,8 +4695,10 @@ static int nf_tables_getset(struct sk_buff *skb, const struct nfnl_info *info,
return -EINVAL; return -EINVAL;
set = nft_set_lookup(table, nla[NFTA_SET_NAME], genmask); 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); return PTR_ERR(set);
}
skb2 = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC); skb2 = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC);
if (skb2 == NULL) if (skb2 == NULL)
...@@ -6025,8 +6027,10 @@ static int nf_tables_getsetelem(struct sk_buff *skb, ...@@ -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); 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); return PTR_ERR(set);
}
nft_ctx_init(&ctx, net, skb, info->nlh, family, table, NULL, nla); 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, ...@@ -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], set = nft_set_lookup_global(net, table, nla[NFTA_SET_ELEM_LIST_SET],
nla[NFTA_SET_ELEM_LIST_SET_ID], genmask); 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); return PTR_ERR(set);
}
if (!list_empty(&set->bindings) && if (!list_empty(&set->bindings) &&
(set->flags & (NFT_SET_CONSTANT | NFT_SET_ANONYMOUS))) (set->flags & (NFT_SET_CONSTANT | NFT_SET_ANONYMOUS)))
...@@ -7195,8 +7201,10 @@ static int nf_tables_delsetelem(struct sk_buff *skb, ...@@ -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); 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); return PTR_ERR(set);
}
if (nft_set_is_anonymous(set)) if (nft_set_is_anonymous(set))
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -8680,6 +8688,7 @@ static int nf_tables_getflowtable(struct sk_buff *skb, ...@@ -8680,6 +8688,7 @@ static int nf_tables_getflowtable(struct sk_buff *skb,
const struct nfnl_info *info, const struct nfnl_info *info,
const struct nlattr * const nla[]) const struct nlattr * const nla[])
{ {
struct netlink_ext_ack *extack = info->extack;
u8 genmask = nft_genmask_cur(info->net); u8 genmask = nft_genmask_cur(info->net);
u8 family = info->nfmsg->nfgen_family; u8 family = info->nfmsg->nfgen_family;
struct nft_flowtable *flowtable; struct nft_flowtable *flowtable;
...@@ -8705,13 +8714,17 @@ static int nf_tables_getflowtable(struct sk_buff *skb, ...@@ -8705,13 +8714,17 @@ static int nf_tables_getflowtable(struct sk_buff *skb,
table = nft_table_lookup(net, nla[NFTA_FLOWTABLE_TABLE], family, table = nft_table_lookup(net, nla[NFTA_FLOWTABLE_TABLE], family,
genmask, 0); genmask, 0);
if (IS_ERR(table)) if (IS_ERR(table)) {
NL_SET_BAD_ATTR(extack, nla[NFTA_FLOWTABLE_TABLE]);
return PTR_ERR(table); return PTR_ERR(table);
}
flowtable = nft_flowtable_lookup(table, nla[NFTA_FLOWTABLE_NAME], flowtable = nft_flowtable_lookup(table, nla[NFTA_FLOWTABLE_NAME],
genmask); genmask);
if (IS_ERR(flowtable)) if (IS_ERR(flowtable)) {
NL_SET_BAD_ATTR(extack, nla[NFTA_FLOWTABLE_NAME]);
return PTR_ERR(flowtable); return PTR_ERR(flowtable);
}
skb2 = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC); skb2 = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC);
if (!skb2) if (!skb2)
......
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