Commit c32c928d authored by Hoang Le's avatar Hoang Le Committed by Jakub Kicinski

tipc: do sanity check payload of a netlink message

When we initialize nlmsghdr with no payload inside tipc_nl_compat_dumpit()
the parsing function returns -EINVAL. We fix it by making the parsing call
conditional.
Acked-by: default avatarJon Maloy <jmaloy@redhat.com>
Signed-off-by: default avatarHoang Le <hoang.h.le@dektech.com.au>
Link: https://lore.kernel.org/r/20201215033151.76139-1-hoang.h.le@dektech.com.auSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 023cae85
......@@ -213,12 +213,14 @@ static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
}
info.attrs = attrbuf;
err = nlmsg_parse_deprecated(cb.nlh, GENL_HDRLEN, attrbuf,
tipc_genl_family.maxattr,
tipc_genl_family.policy, NULL);
if (err)
goto err_out;
if (nlmsg_len(cb.nlh) > 0) {
err = nlmsg_parse_deprecated(cb.nlh, GENL_HDRLEN, attrbuf,
tipc_genl_family.maxattr,
tipc_genl_family.policy, NULL);
if (err)
goto err_out;
}
do {
int rem;
......
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