diff options
| author | Pavel Begunkov <asml.silence@gmail.com> | 2024-11-25 23:10:31 +0000 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-03-22 12:50:45 -0700 |
| commit | b89f95b94cf7bfc7c45c93a1406fe80a86e8c8bb (patch) | |
| tree | 8b10e372bea0ece6cd44100efdce601141f179cf /io_uring/io_uring.c | |
| parent | a0b21f2aca04d4a5dd9f4a0aaf04685970a6b59a (diff) | |
| download | linux-b89f95b94cf7bfc7c45c93a1406fe80a86e8c8bb.tar.gz linux-b89f95b94cf7bfc7c45c93a1406fe80a86e8c8bb.tar.bz2 linux-b89f95b94cf7bfc7c45c93a1406fe80a86e8c8bb.zip | |
io_uring: fix corner case forgetting to vunmap
Commit 43eef70e7e2ac74e7767731dd806720c7fb5e010 upstream.
io_pages_unmap() is a bit tricky in trying to figure whether the pages
were previously vmap'ed or not. In particular If there is juts one page
it belives there is no need to vunmap. Paired io_pages_map(), however,
could've failed io_mem_alloc_compound() and attempted to
io_mem_alloc_single(), which does vmap, and that leads to unpaired vmap.
The solution is to fail if io_mem_alloc_compound() can't allocate a
single page. That's the easiest way to deal with it, and those two
functions are getting removed soon, so no need to overcomplicate it.
Cc: stable@vger.kernel.org
Fixes: 3ab1db3c6039e ("io_uring: get rid of remap_pfn_range() for mapping rings/sqes")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/477e75a3907a2fe83249e49c0a92cd480b2c60e0.1732569842.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'io_uring/io_uring.c')
| -rw-r--r-- | io_uring/io_uring.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 53ec5bb245c8..a2de3c491d27 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -2890,6 +2890,8 @@ static void *io_pages_map(struct page ***out_pages, unsigned short *npages, ret = io_mem_alloc_compound(pages, nr_pages, size, gfp); if (!IS_ERR(ret)) goto done; + if (nr_pages == 1) + goto fail; ret = io_mem_alloc_single(pages, nr_pages, size, gfp); if (!IS_ERR(ret)) { @@ -2898,7 +2900,7 @@ done: *npages = nr_pages; return ret; } - +fail: kvfree(pages); *out_pages = NULL; *npages = 0; |
