Commit 5912a775 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

net: ipv6: addrlabel: perform strict checks also for doit handlers

Make RTM_GETADDRLABEL's doit handler use strict checks when
NETLINK_F_STRICT_CHK is set.
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 38d51810
...@@ -523,6 +523,50 @@ static inline int ip6addrlbl_msgsize(void) ...@@ -523,6 +523,50 @@ static inline int ip6addrlbl_msgsize(void)
+ nla_total_size(4); /* IFAL_LABEL */ + nla_total_size(4); /* IFAL_LABEL */
} }
static int ip6addrlbl_valid_get_req(struct sk_buff *skb,
const struct nlmsghdr *nlh,
struct nlattr **tb,
struct netlink_ext_ack *extack)
{
struct ifaddrlblmsg *ifal;
int i, err;
if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ifal))) {
NL_SET_ERR_MSG_MOD(extack, "Invalid header for addrlabel get request");
return -EINVAL;
}
if (!netlink_strict_get_check(skb))
return nlmsg_parse(nlh, sizeof(*ifal), tb, IFAL_MAX,
ifal_policy, extack);
ifal = nlmsg_data(nlh);
if (ifal->__ifal_reserved || ifal->ifal_flags || ifal->ifal_seq) {
NL_SET_ERR_MSG_MOD(extack, "Invalid values in header for addrlabel get request");
return -EINVAL;
}
err = nlmsg_parse_strict(nlh, sizeof(*ifal), tb, IFAL_MAX,
ifal_policy, extack);
if (err)
return err;
for (i = 0; i <= IFAL_MAX; i++) {
if (!tb[i])
continue;
switch (i) {
case IFAL_ADDRESS:
break;
default:
NL_SET_ERR_MSG_MOD(extack, "Unsupported attribute in addrlabel get request");
return -EINVAL;
}
}
return 0;
}
static int ip6addrlbl_get(struct sk_buff *in_skb, struct nlmsghdr *nlh, static int ip6addrlbl_get(struct sk_buff *in_skb, struct nlmsghdr *nlh,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
...@@ -535,8 +579,7 @@ static int ip6addrlbl_get(struct sk_buff *in_skb, struct nlmsghdr *nlh, ...@@ -535,8 +579,7 @@ static int ip6addrlbl_get(struct sk_buff *in_skb, struct nlmsghdr *nlh,
struct ip6addrlbl_entry *p; struct ip6addrlbl_entry *p;
struct sk_buff *skb; struct sk_buff *skb;
err = nlmsg_parse(nlh, sizeof(*ifal), tb, IFAL_MAX, ifal_policy, err = ip6addrlbl_valid_get_req(in_skb, nlh, tb, extack);
extack);
if (err < 0) if (err < 0)
return err; return err;
......
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