virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Will Deacon <will.deacon@arm.com>
To: linux-kernel@vger.kernel.org
Cc: Marc.Zyngier@arm.com, Will Deacon <will.deacon@arm.com>,
	virtualization@lists.linux-foundation.org, ericvh@gmail.com,
	levinsasha928@gmail.com, akpm@linux-foundation.org
Subject: [PATCH v2 2/3] virtio: 9p: correctly pass physical address to userspace for high pages
Date: Fri, 19 Oct 2012 14:03:32 +0100	[thread overview]
Message-ID: <1350651813-8694-2-git-send-email-will.deacon@arm.com> (raw)
In-Reply-To: <1350651813-8694-1-git-send-email-will.deacon@arm.com>

When using a virtio transport, the 9p net device may pass the physical
address of a kernel buffer to userspace via a scatterlist inside a
virtqueue. If the kernel buffer is mapped outside of the linear mapping
(e.g. highmem), then virt_to_page will return a bogus value and we will
populate the scatterlist with junk.

This patch uses kmap_to_page when populating the page array for a kernel
buffer.

Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
 net/9p/trans_virtio.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index 35b8911..fd05c81 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -39,6 +39,7 @@
 #include <linux/inet.h>
 #include <linux/idr.h>
 #include <linux/file.h>
+#include <linux/highmem.h>
 #include <linux/slab.h>
 #include <net/9p/9p.h>
 #include <linux/parser.h>
@@ -325,7 +326,7 @@ static int p9_get_mapped_pages(struct virtio_chan *chan,
 		int count = nr_pages;
 		while (nr_pages) {
 			s = rest_of_page(data);
-			pages[index++] = virt_to_page(data);
+			pages[index++] = kmap_to_page(data);
 			data += s;
 			nr_pages--;
 		}
-- 
1.7.4.1

  reply	other threads:[~2012-10-19 13:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-19 13:03 [PATCH v2 1/3] mm: highmem: export kmap_to_page for modules Will Deacon
2012-10-19 13:03 ` Will Deacon [this message]
2012-10-22 22:05   ` [PATCH v2 2/3] virtio: 9p: correctly pass physical address to userspace for high pages Andrew Morton
2012-10-19 13:03 ` [PATCH v2 3/3] virtio: force vring descriptors to be allocated from lowmem Will Deacon
2012-10-22 22:08 ` [PATCH v2 1/3] mm: highmem: export kmap_to_page for modules Andrew Morton
2012-10-22 23:55 ` Rusty Russell
2012-10-23 10:33   ` Will Deacon

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=1350651813-8694-2-git-send-email-will.deacon@arm.com \
    --to=will.deacon@arm.com \
    --cc=Marc.Zyngier@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=ericvh@gmail.com \
    --cc=levinsasha928@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.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).