From 09e12a20a4b17c2ab353d73650475d0d866044caa6d3c35b0e5b366d432f54a1 Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Thu, 1 Aug 2013 11:50:51 +0000 Subject: [PATCH 1/2] - Double the size of kvp_send_buffer, for current struct hv_kvp_msg OBS-URL: https://build.opensuse.org/package/show/Virtualization/hyper-v?expand=0&rev=63 --- hyper-v.changes | 5 +++++ hyper-v.tools.hv.hv_kvp_daemon.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/hyper-v.changes b/hyper-v.changes index 5ee0b75..ae9611b 100644 --- a/hyper-v.changes +++ b/hyper-v.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Thu Aug 1 13:49:42 CEST 2013 - ohering@suse.de + +- Double the size of kvp_send_buffer, for current struct hv_kvp_msg + ------------------------------------------------------------------- Wed Jul 24 10:18:34 CEST 2013 - ohering@suse.de diff --git a/hyper-v.tools.hv.hv_kvp_daemon.c b/hyper-v.tools.hv.hv_kvp_daemon.c index d4fcafa..b60c680 100644 --- a/hyper-v.tools.hv.hv_kvp_daemon.c +++ b/hyper-v.tools.hv.hv_kvp_daemon.c @@ -79,7 +79,7 @@ enum { DNS }; -static char kvp_send_buffer[4096]; +static char kvp_send_buffer[4096 * 2]; static char kvp_recv_buffer[4096 * 2]; static struct sockaddr_nl addr; static int in_hand_shake = 1; From d22cc8ce10fc5132dfd63595fca011254fd5f4d9510c61b290281e8a77ed7177 Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Thu, 1 Aug 2013 12:26:23 +0000 Subject: [PATCH 2/2] - Fix send/recv buffer allocation (bnc#828714) OBS-URL: https://build.opensuse.org/package/show/Virtualization/hyper-v?expand=0&rev=64 --- hyper-v.changes | 4 ++-- hyper-v.tools.hv.hv_kvp_daemon.c | 15 ++++++++++++--- hyper-v.tools.hv.hv_vss_daemon.c | 26 +++++++++++++++++++------- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/hyper-v.changes b/hyper-v.changes index ae9611b..8f61615 100644 --- a/hyper-v.changes +++ b/hyper-v.changes @@ -1,7 +1,7 @@ ------------------------------------------------------------------- -Thu Aug 1 13:49:42 CEST 2013 - ohering@suse.de +Thu Aug 1 14:21:57 CEST 2013 - ohering@suse.de -- Double the size of kvp_send_buffer, for current struct hv_kvp_msg +- Fix send/recv buffer allocation (bnc#828714) ------------------------------------------------------------------- Wed Jul 24 10:18:34 CEST 2013 - ohering@suse.de diff --git a/hyper-v.tools.hv.hv_kvp_daemon.c b/hyper-v.tools.hv.hv_kvp_daemon.c index b60c680..252e5d6 100644 --- a/hyper-v.tools.hv.hv_kvp_daemon.c +++ b/hyper-v.tools.hv.hv_kvp_daemon.c @@ -79,8 +79,6 @@ enum { DNS }; -static char kvp_send_buffer[4096 * 2]; -static char kvp_recv_buffer[4096 * 2]; static struct sockaddr_nl addr; static int in_hand_shake = 1; @@ -1437,10 +1435,21 @@ int main(void) int pool; char *if_name; struct hv_kvp_ipaddr_value *kvp_ip_val; + char *kvp_send_buffer; + char *kvp_recv_buffer; + size_t kvp_recv_buffer_len; daemon(1, 0); openlog("KVP", 0, LOG_USER); syslog(LOG_INFO, "KVP starting; pid is:%d", getpid()); + + kvp_recv_buffer_len = NLMSG_HDRLEN + sizeof(struct cn_msg) + sizeof(struct hv_kvp_msg); + kvp_send_buffer = calloc(1, kvp_recv_buffer_len); + kvp_recv_buffer = calloc(1, kvp_recv_buffer_len); + if (!(kvp_send_buffer && kvp_recv_buffer)) { + syslog(LOG_ERR, "Failed to allocate netlink buffers"); + exit(EXIT_FAILURE); + } /* * Retrieve OS release information. */ @@ -1514,7 +1523,7 @@ int main(void) continue; } - len = recvfrom(fd, kvp_recv_buffer, sizeof(kvp_recv_buffer), 0, + len = recvfrom(fd, kvp_recv_buffer, kvp_recv_buffer_len, 0, addr_p, &addr_l); if (len < 0) { diff --git a/hyper-v.tools.hv.hv_vss_daemon.c b/hyper-v.tools.hv.hv_vss_daemon.c index 5b36ea7..797b4c1 100644 --- a/hyper-v.tools.hv.hv_vss_daemon.c +++ b/hyper-v.tools.hv.hv_vss_daemon.c @@ -38,8 +38,6 @@ #include #include -static char vss_recv_buffer[4096]; -static char vss_send_buffer[4096]; static struct sockaddr_nl addr; #ifndef SOL_NETLINK @@ -52,7 +50,7 @@ static int vss_do_freeze(char *dir, unsigned int cmd, char *fs_op) int ret, fd = open(dir, O_RDONLY); if (fd < 0) - return -1; + return 1; ret = ioctl(fd, cmd, 0); syslog(LOG_INFO, "VSS: %s of %s: %s\n", fs_op, dir, strerror(errno)); close(fd); @@ -85,9 +83,11 @@ static int vss_operate(int operation) if (mounts == NULL) return -1; - while((ent = getmntent(mounts))) { + while ((ent = getmntent(mounts))) { if (strncmp(ent->mnt_fsname, match, strlen(match))) continue; + if (strcmp(ent->mnt_type, "iso9660") == 0) + continue; if (strcmp(ent->mnt_dir, "/") == 0) { root_seen = 1; continue; @@ -145,6 +145,9 @@ int main(void) struct cn_msg *incoming_cn_msg; int op; struct hv_vss_msg *vss_msg; + char *vss_send_buffer; + char *vss_recv_buffer; + size_t vss_recv_buffer_len; if (daemon(1, 0)) return 1; @@ -152,6 +155,14 @@ int main(void) openlog("Hyper-V VSS", 0, LOG_USER); syslog(LOG_INFO, "VSS starting; pid is:%d", getpid()); + vss_recv_buffer_len = NLMSG_HDRLEN + sizeof(struct cn_msg) + sizeof(struct hv_vss_msg); + vss_send_buffer = calloc(1, vss_recv_buffer_len); + vss_recv_buffer = calloc(1, vss_recv_buffer_len); + if (!(vss_send_buffer && vss_recv_buffer)) { + syslog(LOG_ERR, "Failed to allocate netlink buffers"); + exit(EXIT_FAILURE); + } + fd = socket(AF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR); if (fd < 0) { syslog(LOG_ERR, "netlink socket creation failed; error:%d", fd); @@ -199,7 +210,7 @@ int main(void) pfd.revents = 0; poll(&pfd, 1, -1); - len = recvfrom(fd, vss_recv_buffer, sizeof(vss_recv_buffer), 0, + len = recvfrom(fd, vss_recv_buffer, vss_recv_buffer_len, 0, addr_p, &addr_l); if (len < 0) { @@ -210,8 +221,9 @@ int main(void) } if (addr.nl_pid) { - syslog(LOG_WARNING, "Received packet from untrusted pid:%u", - addr.nl_pid); + syslog(LOG_WARNING, + "Received packet from untrusted pid:%u", + addr.nl_pid); continue; }