summaryrefslogtreecommitdiffstats
path: root/io_uring
diff options
context:
space:
mode:
authorTobias Holl <tobias@tholl.xyz>2023-05-03 08:59:50 -0600
committerJens Axboe <axboe@kernel.dk>2023-05-03 09:00:22 -0600
commit776617db78c6d208780e7c69d4d68d1fa82913de (patch)
tree8c81c3a20db72058af205842f0c34a809f64c830 /io_uring
parent3c85cc43c8e7855d202da184baf00c7b8eeacf71 (diff)
downloadlinux-776617db78c6d208780e7c69d4d68d1fa82913de.tar.gz
linux-776617db78c6d208780e7c69d4d68d1fa82913de.tar.bz2
linux-776617db78c6d208780e7c69d4d68d1fa82913de.zip
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 57bebf807e2a ("io_uring/rsrc: optimise registered huge pages"), check that the memory is actually consecutive. Cc: stable@vger.kernel.org Fixes: 57bebf807e2a ("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>
Diffstat (limited to 'io_uring')
-rw-r--r--io_uring/rsrc.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index ddee7adb4006..00affcf811ad 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -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;
}