Skip to content

Commit

Permalink
io_uring/rsrc: check for nonconsecutive pages
Browse files Browse the repository at this point in the history
commit 776617d upstream.

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 57bebf8
("io_uring/rsrc: optimise registered huge pages"), check that the memory
is actually consecutive.

Cc: stable@vger.kernel.org
Fixes: 57bebf8 ("io_uring/rsrc: optimise registered huge pages")
Signed-off-by: Tobias Holl <tobias@tholl.xyz>
[axboe: formatting]
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Tobias Holl authored and gregkh committed May 11, 2023
1 parent 8bc13e3 commit 3a0a921
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion io_uring/rsrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,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;
}
Expand Down

0 comments on commit 3a0a921

Please sign in to comment.