Thread (62 messages) 62 messages, 4 authors, 2018-10-08

Re: [PATCH net-next 02/20] netlink: Add extack message to nlmsg_parse for invalid header length

From: Christian Brauner <christian@brauner.io>
Date: 2018-10-06 00:41:44

On Thu, Oct 04, 2018 at 02:33:37PM -0700, David Ahern wrote:
From: David Ahern <redacted>

Give a user a reason why EINVAL is returned in nlmsg_parse.

Signed-off-by: David Ahern <redacted>
Acked-by: Christian Brauner <christian@brauner.io>
quoted hunk ↗ jump to hunk
---
 include/net/netlink.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/include/net/netlink.h b/include/net/netlink.h
index 589683091f16..9522a0bf1f3a 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -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);
-- 
2.11.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help