net: ipv6: netconf: perform strict checks also for doit handlers
Make RTM_GETNETCONF's doit handler use strict checks when NETLINK_F_STRICT_CHK is set. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Родитель
4b1373de73
Коммит
38d51810c4
|
@ -597,6 +597,43 @@ static const struct nla_policy devconf_ipv6_policy[NETCONFA_MAX+1] = {
|
|||
[NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN] = { .len = sizeof(int) },
|
||||
};
|
||||
|
||||
static int inet6_netconf_valid_get_req(struct sk_buff *skb,
|
||||
const struct nlmsghdr *nlh,
|
||||
struct nlattr **tb,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
int i, err;
|
||||
|
||||
if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(struct netconfmsg))) {
|
||||
NL_SET_ERR_MSG_MOD(extack, "Invalid header for netconf get request");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!netlink_strict_get_check(skb))
|
||||
return nlmsg_parse(nlh, sizeof(struct netconfmsg), tb,
|
||||
NETCONFA_MAX, devconf_ipv6_policy, extack);
|
||||
|
||||
err = nlmsg_parse_strict(nlh, sizeof(struct netconfmsg), tb,
|
||||
NETCONFA_MAX, devconf_ipv6_policy, extack);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
for (i = 0; i <= NETCONFA_MAX; i++) {
|
||||
if (!tb[i])
|
||||
continue;
|
||||
|
||||
switch (i) {
|
||||
case NETCONFA_IFINDEX:
|
||||
break;
|
||||
default:
|
||||
NL_SET_ERR_MSG_MOD(extack, "Unsupported attribute in netconf get request");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int inet6_netconf_get_devconf(struct sk_buff *in_skb,
|
||||
struct nlmsghdr *nlh,
|
||||
struct netlink_ext_ack *extack)
|
||||
|
@ -605,14 +642,12 @@ static int inet6_netconf_get_devconf(struct sk_buff *in_skb,
|
|||
struct nlattr *tb[NETCONFA_MAX+1];
|
||||
struct inet6_dev *in6_dev = NULL;
|
||||
struct net_device *dev = NULL;
|
||||
struct netconfmsg *ncm;
|
||||
struct sk_buff *skb;
|
||||
struct ipv6_devconf *devconf;
|
||||
int ifindex;
|
||||
int err;
|
||||
|
||||
err = nlmsg_parse(nlh, sizeof(*ncm), tb, NETCONFA_MAX,
|
||||
devconf_ipv6_policy, extack);
|
||||
err = inet6_netconf_valid_get_req(in_skb, nlh, tb, extack);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче