From: "Matej Mužila" <mmuzila@redhat.com>
To: devel@linuxdriverproject.org, linux-kernel@vger.kernel.org,
kys@microsoft.com
Cc: dan.carpenter@oracle.com,
One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
Subject: [PATCH v2 1/3] tools: hv: fcopy_daemon: Check buffer limits
Date: Tue, 21 Oct 2014 16:46:58 +0200 [thread overview]
Message-ID: <544671E2.3000905@redhat.com> (raw)
In-Reply-To: <544658CE.8050704@redhat.com>
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.
Changes made since v1:
* max value of cmesg->size is now derived from structure
definition in sources/include/uapi/linux/hyperv.h
* Fixed comments
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);
next prev parent reply other threads:[~2014-10-21 14:47 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
2014-10-21 14:17 ` Dan Carpenter
2014-10-21 14:46 ` Matej Mužila [this message]
2014-11-07 18:19 ` [PATCH v2 " 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=544671E2.3000905@redhat.com \
--to=mmuzila@redhat.com \
--cc=dan.carpenter@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).