Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: stable@kernel.org
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

authored by

Will Deacon and committed by
Rusty Russell
b9cdc88d f0263d2d

+2 -1
+2 -1
net/9p/trans_virtio.c
··· 39 39 #include <linux/inet.h> 40 40 #include <linux/idr.h> 41 41 #include <linux/file.h> 42 + #include <linux/highmem.h> 42 43 #include <linux/slab.h> 43 44 #include <net/9p/9p.h> 44 45 #include <linux/parser.h> ··· 326 325 int count = nr_pages; 327 326 while (nr_pages) { 328 327 s = rest_of_page(data); 329 - pages[index++] = virt_to_page(data); 328 + pages[index++] = kmap_to_page(data); 330 329 data += s; 331 330 nr_pages--; 332 331 }