mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marcus Meissner <meissner@suse.de>
To: gregkh@linuxfoundation.org, kys@microsoft.com,
	dan.carpenter@oracle.com, haiyangz@microsoft.com,
	jkosina@suse.cz, linux-kernel@vger.kernel.org, stable@kernel.org
Cc: Marcus Meissner <meissner@suse.de>,
	Sebastian Krahmer <krahmer@suse.de>,
	Olaf Hering <ohering@suse.de>
Subject: [PATCH] tools/hv: Check the source of netlink messages to be the kernel
Date: Thu,  7 Jun 2012 11:07:48 +0200	[thread overview]
Message-ID: <1339060068-19951-1-git-send-email-meissner@suse.de> (raw)

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

Signed-off-by: Marcus Meissner <meissner@suse.de>
Signed-off-by: Sebastian Krahmer <krahmer@suse.de>
Signed-off-by: Olaf Hering <ohering@suse.de>
---
 tools/hv/hv_kvp_daemon.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
index 146fd61..f0566c8 100644
--- a/tools/hv/hv_kvp_daemon.c
+++ b/tools/hv/hv_kvp_daemon.c
@@ -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;
 		}
-- 
1.7.9.2


             reply	other threads:[~2012-06-07  9:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-07  9:07 Marcus Meissner [this message]
2012-06-07 12:38 ` KY Srinivasan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1339060068-19951-1-git-send-email-meissner@suse.de \
    --to=meissner@suse.de \
    --cc=dan.carpenter@oracle.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=haiyangz@microsoft.com \
    --cc=jkosina@suse.cz \
    --cc=krahmer@suse.de \
    --cc=kys@microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ohering@suse.de \
    --cc=stable@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®