Skip to content

Commit 223ef47

Browse files
committed
io_uring: don't allow IORING_SETUP_NO_MMAP rings on highmem pages
On at least arm32, but presumably any arch with highmem, if the application passes in memory that resides in highmem for the rings, then we should fail that ring creation. We fail it with -EINVAL, which is what kernels that don't support IORING_SETUP_NO_MMAP will do as well. Cc: stable@vger.kernel.org Fixes: 03d89a2 ("io_uring: support for user allocated memory for rings/sqes") Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 1658633 commit 223ef47

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

io_uring/io_uring.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2686,7 +2686,7 @@ static void *__io_uaddr_map(struct page ***pages, unsigned short *npages,
26862686
{
26872687
struct page **page_array;
26882688
unsigned int nr_pages;
2689-
int ret;
2689+
int ret, i;
26902690

26912691
*npages = 0;
26922692

@@ -2716,6 +2716,20 @@ static void *__io_uaddr_map(struct page ***pages, unsigned short *npages,
27162716
*/
27172717
if (page_array[0] != page_array[ret - 1])
27182718
goto err;
2719+
2720+
/*
2721+
* Can't support mapping user allocated ring memory on 32-bit archs
2722+
* where it could potentially reside in highmem. Just fail those with
2723+
* -EINVAL, just like we did on kernels that didn't support this
2724+
* feature.
2725+
*/
2726+
for (i = 0; i < nr_pages; i++) {
2727+
if (PageHighMem(page_array[i])) {
2728+
ret = -EINVAL;
2729+
goto err;
2730+
}
2731+
}
2732+
27192733
*pages = page_array;
27202734
*npages = nr_pages;
27212735
return page_to_virt(page_array[0]);

0 commit comments

Comments
 (0)