Skip to content

Commit 3d0d433

Browse files
dsaherndavem330
authored andcommitted
netlink: Add extack message to nlmsg_parse for invalid header length
Give a user a reason why EINVAL is returned in nlmsg_parse. Signed-off-by: David Ahern <[email protected]> Acked-by: Christian Brauner <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4a19edb commit 3d0d433

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

include/net/netlink.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,10 @@ static inline int nlmsg_parse(const struct nlmsghdr *nlh, int hdrlen,
516516
const struct nla_policy *policy,
517517
struct netlink_ext_ack *extack)
518518
{
519-
if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen))
519+
if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen)) {
520+
NL_SET_ERR_MSG(extack, "Invalid header length");
520521
return -EINVAL;
522+
}
521523

522524
return nla_parse(tb, maxtype, nlmsg_attrdata(nlh, hdrlen),
523525
nlmsg_attrlen(nlh, hdrlen), policy, extack);

0 commit comments

Comments
 (0)