Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlaf Hering <ohering@suse.de>2017-10-20 12:20:33 +0200
committerOlaf Hering <ohering@suse.de>2017-10-20 12:23:28 +0200
commitfb1fb2bc950c9079cec952b0927290dd088cf652 (patch)
treee5b2d59ad0f1fa56a37fe702dd56a5882c00f4c7
parentc6e68e69ea532a81e9a874430428c245a866ab65 (diff)
Tools: hv: update buffer handling in hv_fcopy_daemon
-rw-r--r--patches.suse/msft-hv-1441-Tools-hv-update-buffer-handling-in-hv_fcopy_daemon.patch100
-rw-r--r--series.conf1
2 files changed, 101 insertions, 0 deletions
diff --git a/patches.suse/msft-hv-1441-Tools-hv-update-buffer-handling-in-hv_fcopy_daemon.patch b/patches.suse/msft-hv-1441-Tools-hv-update-buffer-handling-in-hv_fcopy_daemon.patch
new file mode 100644
index 0000000000..5edddb2bbb
--- /dev/null
+++ b/patches.suse/msft-hv-1441-Tools-hv-update-buffer-handling-in-hv_fcopy_daemon.patch
@@ -0,0 +1,100 @@
+From: Olaf Hering <olaf@aepfle.de>
+Date: Thu, 10 Aug 2017 15:45:16 -0700
+Patch-mainline: v4.14-rc1
+Subject: Tools: hv: update buffer handling in hv_fcopy_daemon
+Git-commit: 3f2baa8a7d2efaa836f1dc4b8ee8c3ca4ba9e101
+References: fate#323887
+
+Currently this warning is triggered when compiling hv_fcopy_daemon:
+
+hv_fcopy_daemon.c:216:4: warning: dereferencing type-punned pointer will break
+strict-aliasing rules [-Wstrict-aliasing]
+ kernel_modver = *(__u32 *)buffer;
+
+Convert the send/receive buffer to a union and pass individual members as
+needed. This also gives the correct size for the buffer.
+
+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>
+Acked-by: Olaf Hering <ohering@suse.de>
+---
+ tools/hv/hv_fcopy_daemon.c | 32 +++++++++++++++++---------------
+ 1 file changed, 17 insertions(+), 15 deletions(-)
+
+diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c
+--- a/tools/hv/hv_fcopy_daemon.c
++++ b/tools/hv/hv_fcopy_daemon.c
+@@ -138,14 +138,17 @@ void print_usage(char *argv[])
+
+ int main(int argc, char *argv[])
+ {
+- int fcopy_fd, len;
++ int fcopy_fd;
+ int error;
+ int daemonize = 1, long_index = 0, opt;
+ int version = FCOPY_CURRENT_VERSION;
+- char *buffer[4096 * 2];
+- struct hv_fcopy_hdr *in_msg;
++ union {
++ struct hv_fcopy_hdr hdr;
++ struct hv_start_fcopy start;
++ struct hv_do_fcopy copy;
++ __u32 kernel_modver;
++ } buffer = { };
+ int in_handshake = 1;
+- __u32 kernel_modver;
+
+ static struct option long_options[] = {
+ {"help", no_argument, 0, 'h' },
+@@ -195,32 +198,31 @@ int main(int argc, char *argv[])
+ * In this loop we process fcopy messages after the
+ * handshake is complete.
+ */
+- len = pread(fcopy_fd, buffer, (4096 * 2), 0);
++ ssize_t len;
++
++ len = pread(fcopy_fd, &buffer, sizeof(buffer), 0);
+ if (len < 0) {
+ syslog(LOG_ERR, "pread failed: %s", strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+
+ if (in_handshake) {
+- if (len != sizeof(kernel_modver)) {
++ if (len != sizeof(buffer.kernel_modver)) {
+ syslog(LOG_ERR, "invalid version negotiation");
+ exit(EXIT_FAILURE);
+ }
+- kernel_modver = *(__u32 *)buffer;
+ in_handshake = 0;
+- syslog(LOG_INFO, "kernel module version: %d",
+- kernel_modver);
++ syslog(LOG_INFO, "kernel module version: %u",
++ buffer.kernel_modver);
+ continue;
+ }
+
+- in_msg = (struct hv_fcopy_hdr *)buffer;
+-
+- switch (in_msg->operation) {
++ switch (buffer.hdr.operation) {
+ case START_FILE_COPY:
+- error = hv_start_fcopy((struct hv_start_fcopy *)in_msg);
++ error = hv_start_fcopy(&buffer.start);
+ break;
+ case WRITE_TO_FILE:
+- error = hv_copy_data((struct hv_do_fcopy *)in_msg);
++ error = hv_copy_data(&buffer.copy);
+ break;
+ case COMPLETE_FCOPY:
+ error = hv_copy_finished();
+@@ -231,7 +233,7 @@ int main(int argc, char *argv[])
+
+ default:
+ syslog(LOG_ERR, "Unknown operation: %d",
+- in_msg->operation);
++ buffer.hdr.operation);
+
+ }
+
diff --git a/series.conf b/series.conf
index 9c08aa6543..abe5dfa303 100644
--- a/series.conf
+++ b/series.conf
@@ -1691,6 +1691,7 @@
patches.suse/msft-hv-1438-Drivers-hv-balloon-Initialize-last_post_time-on-star.patch
patches.suse/msft-hv-1439-Drivers-hv-kvp-Use-MAX_ADAPTER_ID_SIZE-for-translati.patch
patches.suse/msft-hv-1440-Tools-hv-fix-snprintf-warning-in-kvp_daemon.patch
+ patches.suse/msft-hv-1441-Tools-hv-update-buffer-handling-in-hv_fcopy_daemon.patch
patches.suse/suse-hv-guest-os-id.patch
patches.suse/suse-hv-kvp_on_msg.dbg.patch