All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Matej Mužila" <mmuzila@redhat.com>
To: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
Cc: kys@microsoft.com, devel@linuxdriverproject.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] tools: hv: fcopy_daemon: Check buffer limits
Date: Tue, 21 Oct 2014 14:59:58 +0200	[thread overview]
Message-ID: <544658CE.8050704@redhat.com> (raw)
In-Reply-To: <20141021131357.3677c4a5@alan.etchedpixels.co.uk>

> sizeof(__u8) is by definition 1 so it's perhaps surplus ?
Now the size is now determined from the structure definition in
include/uapi/linux/hyperv.h

> - C style comments for coding style
Fixed

> Also your patch block is devoid of a few thins like the file name...
I'm sorry, the (missing) filename mistake occured in copy-paste process.


Here is the patch as it (I hope) should look like:
---
From: Matej Mužila <mmuzila@redhat.com>

Check if cpmsg->size is in limits of DATA_FRAGMENT

Signed-off-by: Matej Mužila <mmuzila@redhat.com>
---
If corrupted data are read from /dev/vmbus/hv_fcopy, pwrite can
read from memory outside of the buffer (defined at line 138).
Added check. 
---
diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c
index 6f27e2f..1fc2dc2 100644
--- a/tools/hv/hv_fcopy_daemon.c
+++ b/tools/hv/hv_fcopy_daemon.c
@@ -104,6 +104,10 @@ static int hv_copy_data(struct hv_do_fcopy *cpmsg)
 {
 	ssize_t bytes_written;
 
+	/* Check if the cpmsg->size is in limits of DATA_FRAGMENT */
+	if (cpmsg->size > sizeof(cpmsg->data)) 
+		return HV_E_FAIL;
+
 	bytes_written = pwrite(target_fd, cpmsg->data, cpmsg->size,
 				cpmsg->offset);


  reply	other threads:[~2014-10-21 13:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-21 11:49 [PATCH 1/3] tools: hv: fcopy_daemon: Check buffer limits Matej Mužila
2014-10-21 12:13 ` One Thousand Gnomes
2014-10-21 12:59   ` Matej Mužila [this message]
2014-10-21 14:17     ` Dan Carpenter
2014-10-21 14:46     ` [PATCH v2 " Matej Mužila
2014-11-07 18:19       ` Greg KH

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=544658CE.8050704@redhat.com \
    --to=mmuzila@redhat.com \
    --cc=devel@linuxdriverproject.org \
    --cc=gnomes@lxorguk.ukuu.org.uk \
    --cc=kys@microsoft.com \
    --cc=linux-kernel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.