Commit 776617db authored by Tobias Holl's avatar Tobias Holl Committed by Jens Axboe

io_uring/rsrc: check for nonconsecutive pages

Pages that are from the same folio do not necessarily need to be
consecutive. In that case, we cannot consolidate them into a single bvec
entry. Before applying the huge page optimization from commit 57bebf80
("io_uring/rsrc: optimise registered huge pages"), check that the memory
is actually consecutive.

Cc: stable@vger.kernel.org
Fixes: 57bebf80 ("io_uring/rsrc: optimise registered huge pages")
Signed-off-by: default avatarTobias Holl <tobias@tholl.xyz>
[axboe: formatting]
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 3c85cc43
......@@ -1117,7 +1117,12 @@ static int io_sqe_buffer_register(struct io_ring_ctx *ctx, struct iovec *iov,
if (nr_pages > 1) {
folio = page_folio(pages[0]);
for (i = 1; i < nr_pages; i++) {
if (page_folio(pages[i]) != folio) {
/*
* Pages must be consecutive and on the same folio for
* this to work
*/
if (page_folio(pages[i]) != folio ||
pages[i] != pages[i - 1] + 1) {
folio = NULL;
break;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment