tools/hv: Check the source of netlink messages to be the kernel
PATCH 1/1 tools/hv: Check the source of netlink messages to be the kernel
Hi,
The hyper-v userspace helper daemon receives and handles netlink messages. It assumes them to be from the kernel, but does not check that.
This patch adds this checking (nl_pid == 0).
CVE-2012-2669
Ciao, Marcus
--- tools/hv/hv_kvp_daemon.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
tools/hv/hv_kvp_daemon.c +5 -3
@@ -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 ; }
Signature · 1 line
1.7.9.2
Quoted 19 lines
-----Original Message-----
From: Marcus Meissner [mailto:[email protected]]
Sent: Thursday, June 07, 2012 5:08 AM
To: [email protected]; KY Srinivasan; [email protected]; Haiyang Zhang; [email protected]; [email protected]; [email protected]
Cc: Marcus Meissner; Sebastian Krahmer; Olaf Hering
Subject: [PATCH]tools/hv: Check the source of netlink messages to be the kernelHi,
The hyper-v userspace helper daemon receives and handles netlink messages. It assumes them to be from the kernel, but does not check that.
This patch adds this checking (
nl_pid== 0).
Quoted 7 lines
CVE-2012-2669
Ciao, Marcus
Signed-off-by Marcus Meissner <[email protected]>Signed-off-by Sebastian Krahmer <[email protected]>Signed-off-by Olaf Hering <[email protected]>
Olaf already posted this patch and I signed off on it.
Regards,
K. Y
Quoted 35 lines
--- tools/hv/hv_kvp_daemon.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)tools/hv/hv_kvp_daemon.c +5
-3@@ -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);tools/hv/hv_kvp_daemon.c +0
-1return -1 ; } --1.7.9.2