提交 2bc41ea3 编写于 作者: O Olaf Hering 提交者: Greg Kroah-Hartman

Tools: hv: correct payload size in netlink_send

netlink_send is supposed to send just the cn_msg+hv_kvp_msg via netlink.
Currently it sets an incorrect iovec size, as reported by valgrind.

In the case of registering with the kernel the allocated buffer is large
enough to hold nlmsghdr+cn_msg+hv_kvp_msg, no overrun happens. In the
case of responding to the kernel the cn_msg is located in the middle of
recv_buffer, after the nlmsghdr. Currently the code in netlink_send adds
also the size of nlmsghdr to the payload. But nlmsghdr is a separate
iovec. This leads to an (harmless) out-of-bounds access when the kernel
processes the iovec. Correct the iovec size of the cn_msg to be just
cn_msg + its payload.
Signed-off-by: NOlaf Hering <olaf@aepfle.de>
Signed-off-by: NK. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 d3b688c6
...@@ -1398,7 +1398,7 @@ netlink_send(int fd, struct cn_msg *msg) ...@@ -1398,7 +1398,7 @@ netlink_send(int fd, struct cn_msg *msg)
char buffer[64]; char buffer[64];
struct iovec iov[2]; struct iovec iov[2];
size = NLMSG_SPACE(sizeof(struct cn_msg) + msg->len); size = sizeof(struct cn_msg) + msg->len;
nlh = (struct nlmsghdr *)buffer; nlh = (struct nlmsghdr *)buffer;
nlh->nlmsg_seq = 0; nlh->nlmsg_seq = 0;
......
...@@ -111,7 +111,7 @@ static int netlink_send(int fd, struct cn_msg *msg) ...@@ -111,7 +111,7 @@ static int netlink_send(int fd, struct cn_msg *msg)
char buffer[64]; char buffer[64];
struct iovec iov[2]; struct iovec iov[2];
size = NLMSG_SPACE(sizeof(struct cn_msg) + msg->len); size = sizeof(struct cn_msg) + msg->len;
nlh = (struct nlmsghdr *)buffer; nlh = (struct nlmsghdr *)buffer;
nlh->nlmsg_seq = 0; nlh->nlmsg_seq = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册