From: Michal Kubecek Date: Thu, 2 May 2019 14:15:10 +0000 (+0200) Subject: netlink: set bad attribute also on maxtype check X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=d54a16b20157ce300298eb4a1169bf9acfda3d08;p=linux.git netlink: set bad attribute also on maxtype check The check that attribute type is within 0...maxtype range in __nla_validate_parse() sets only error message but not bad_attr in extack. Set also bad_attr to tell userspace which attribute failed validation. Signed-off-by: Michal Kubecek Reviewed-by: Johannes Berg Reviewed-by: David Ahern Signed-off-by: David S. Miller --- diff --git a/lib/nlattr.c b/lib/nlattr.c index 29f6336e2422b..adc919b32bf92 100644 --- a/lib/nlattr.c +++ b/lib/nlattr.c @@ -356,7 +356,8 @@ static int __nla_validate_parse(const struct nlattr *head, int len, int maxtype, if (type == 0 || type > maxtype) { if (validate & NL_VALIDATE_MAXTYPE) { - NL_SET_ERR_MSG(extack, "Unknown attribute type"); + NL_SET_ERR_MSG_ATTR(extack, nla, + "Unknown attribute type"); return -EINVAL; } continue;