From 169a723b609b8247fb15d8e127b131f472dc6d1d61fcebd306b62487069eba98 Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Wed, 16 May 2012 18:45:41 +0000 Subject: [PATCH] - check origin of netlink messages, use recvfrom() [bnc#761200] OBS-URL: https://build.opensuse.org/package/show/Virtualization/hyper-v?expand=0&rev=25 --- hyper-v.changes | 5 +++++ hyper-v.spec | 6 +++++- hyper-v.tools.hv.hv_kvp_daemon.c.patch | 22 ++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 hyper-v.tools.hv.hv_kvp_daemon.c.patch diff --git a/hyper-v.changes b/hyper-v.changes index c908f35..56e44f3 100644 --- a/hyper-v.changes +++ b/hyper-v.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Wed May 16 20:44:36 CEST 2012 - ohering@suse.de + +- check origin of netlink messages, use recvfrom() [bnc#761200] + ------------------------------------------------------------------- Wed May 2 12:13:03 CEST 2012 - ohering@suse.de diff --git a/hyper-v.spec b/hyper-v.spec index a2aa756..8db7dc0 100644 --- a/hyper-v.spec +++ b/hyper-v.spec @@ -49,6 +49,7 @@ Source5: hyper-v.kvptest.ps1.txt Source9: hyper-v.include.linux.hyperv.h Source10: hyper-v.tools.hv.hv_kvp_daemon.c Source11: hyper-v.init.sh +Patch761200: hyper-v.tools.hv.hv_kvp_daemon.c.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build %if %{with_kmp} %if %{with_drivers_in_kmp} @@ -82,11 +83,14 @@ This package contains the Microsoft Hyper-V drivers. cp -avL %{S:5} kvptest.ps1.txt cp -vL %{S:9} %{hv_kvp_daemon}.h cp -vL %{S:10} %{hv_kvp_daemon}.c -sed -i~ '/#include /d' %{hv_kvp_daemon}.c +%patch761200 -p0 %build +sed -i~ '/#include /d' %{hv_kvp_daemon}.c gcc \ $RPM_OPT_FLAGS \ + -Wno-unused-variable \ + -Wno-pointer-sign \ -g \ %{hv_kvp_daemon}.c \ -include %{hv_kvp_daemon}.h \ diff --git a/hyper-v.tools.hv.hv_kvp_daemon.c.patch b/hyper-v.tools.hv.hv_kvp_daemon.c.patch new file mode 100644 index 0000000..2efecb1 --- /dev/null +++ b/hyper-v.tools.hv.hv_kvp_daemon.c.patch @@ -0,0 +1,22 @@ +--- hv_kvp_daemon.c.orig 2012-05-16 20:11:10.000000000 +0200 ++++ hv_kvp_daemon.c 2012-05-16 20:40:08.000000000 +0200 +@@ -701,14 +701,16 @@ int main(void) + pfd.fd = fd; + + while (1) { ++ struct sockaddr *addr_p = (struct sockaddr *) &addr; ++ socklen_t addr_l = sizeof(addr); + pfd.events = POLLIN; + pfd.revents = 0; + poll(&pfd, 1, -1); + +- len = recv(fd, kvp_recv_buffer, sizeof(kvp_recv_buffer), 0); ++ len = recvfrom(fd, kvp_recv_buffer, sizeof(kvp_recv_buffer), 0, addr_p, &addr_l); + +- if (len < 0) { +- syslog(LOG_ERR, "recv failed; error:%d", len); ++ if (len < 0 || addr.nl_pid) { ++ syslog(LOG_ERR, "recvfrom failed; pid:%u error:%d %s", addr.nl_pid, errno, strerror(errno)); + close(fd); + return -1; + }