Skip to content

Commit b9cdc88

Browse files
wildea01rustyrussell
authored andcommitted
virtio: 9p: correctly pass physical address to userspace for high pages
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: [email protected] Cc: Sasha Levin <[email protected]> Signed-off-by: Will Deacon <[email protected]> Signed-off-by: Rusty Russell <[email protected]>
1 parent f0263d2 commit b9cdc88

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/9p/trans_virtio.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include <linux/inet.h>
4040
#include <linux/idr.h>
4141
#include <linux/file.h>
42+
#include <linux/highmem.h>
4243
#include <linux/slab.h>
4344
#include <net/9p/9p.h>
4445
#include <linux/parser.h>
@@ -325,7 +326,7 @@ static int p9_get_mapped_pages(struct virtio_chan *chan,
325326
int count = nr_pages;
326327
while (nr_pages) {
327328
s = rest_of_page(data);
328-
pages[index++] = virt_to_page(data);
329+
pages[index++] = kmap_to_page(data);
329330
data += s;
330331
nr_pages--;
331332
}

0 commit comments

Comments
 (0)