]> git.baikalelectronics.ru Git - kernel.git/commitdiff
netlink: Add extack message to nlmsg_parse for invalid header length
authorDavid Ahern <dsahern@gmail.com>
Mon, 8 Oct 2018 03:16:23 +0000 (20:16 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 8 Oct 2018 17:39:03 +0000 (10:39 -0700)
Give a user a reason why EINVAL is returned in nlmsg_parse.

Signed-off-by: David Ahern <dsahern@gmail.com>
Acked-by: Christian Brauner <christian@brauner.io>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/netlink.h

index 589683091f16790290e368449349b9451bb09626..9522a0bf1f3af5046f713e99c7be75cc183b31c2 100644 (file)
@@ -516,8 +516,10 @@ static inline int nlmsg_parse(const struct nlmsghdr *nlh, int hdrlen,
                              const struct nla_policy *policy,
                              struct netlink_ext_ack *extack)
 {
-       if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen))
+       if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen)) {
+               NL_SET_ERR_MSG(extack, "Invalid header length");
                return -EINVAL;
+       }
 
        return nla_parse(tb, maxtype, nlmsg_attrdata(nlh, hdrlen),
                         nlmsg_attrlen(nlh, hdrlen), policy, extack);