Commit b9cdc88df8e63e81c723b82c286fc97f5d0dc325
Committed by
Rusty Russell
1 parent
f0263d2d22
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
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>
Showing 1 changed file with 2 additions and 1 deletions Side-by-side Diff
net/9p/trans_virtio.c
... | ... | @@ -39,6 +39,7 @@ |
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> |
... | ... | @@ -325,7 +326,7 @@ |
325 | 326 | int count = nr_pages; |
326 | 327 | while (nr_pages) { |
327 | 328 | s = rest_of_page(data); |
328 | - pages[index++] = virt_to_page(data); | |
329 | + pages[index++] = kmap_to_page(data); | |
329 | 330 | data += s; |
330 | 331 | nr_pages--; |
331 | 332 | } |