Skip to content

Commit 2bc41ea

Browse files
olafheringgregkh
authored andcommitted
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: Olaf Hering <olaf@aepfle.de> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d3b688c commit 2bc41ea

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎tools/hv/hv_kvp_daemon.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1398,7 +1398,7 @@ netlink_send(int fd, struct cn_msg *msg)
13981398
char buffer[64];
13991399
struct iovec iov[2];
14001400

1401-
size = NLMSG_SPACE(sizeof(struct cn_msg) + msg->len);
1401+
size = sizeof(struct cn_msg) + msg->len;
14021402

14031403
nlh = (struct nlmsghdr *)buffer;
14041404
nlh->nlmsg_seq = 0;

‎tools/hv/hv_vss_daemon.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static int netlink_send(int fd, struct cn_msg *msg)
111111
char buffer[64];
112112
struct iovec iov[2];
113113

114-
size = NLMSG_SPACE(sizeof(struct cn_msg) + msg->len);
114+
size = sizeof(struct cn_msg) + msg->len;
115115

116116
nlh = (struct nlmsghdr *)buffer;
117117
nlh->nlmsg_seq = 0;

0 commit comments

Comments
 (0)