Skip to content

Commit

Permalink
io_uring: don't allow IORING_SETUP_NO_MMAP rings on highmem pages
Browse files Browse the repository at this point in the history
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: [email protected]
Fixes: 03d89a2 ("io_uring: support for user allocated memory for rings/sqes")
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Oct 3, 2023
1 parent 1658633 commit 223ef47
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion io_uring/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -2686,7 +2686,7 @@ static void *__io_uaddr_map(struct page ***pages, unsigned short *npages,
{
struct page **page_array;
unsigned int nr_pages;
int ret;
int ret, i;

*npages = 0;

Expand Down Expand Up @@ -2716,6 +2716,20 @@ static void *__io_uaddr_map(struct page ***pages, unsigned short *npages,
*/
if (page_array[0] != page_array[ret - 1])
goto err;

/*
* Can't support mapping user allocated ring memory on 32-bit archs
* where it could potentially reside in highmem. Just fail those with
* -EINVAL, just like we did on kernels that didn't support this
* feature.
*/
for (i = 0; i < nr_pages; i++) {
if (PageHighMem(page_array[i])) {
ret = -EINVAL;
goto err;
}
}

*pages = page_array;
*npages = nr_pages;
return page_to_virt(page_array[0]);
Expand Down

0 comments on commit 223ef47

Please sign in to comment.