]> git.itanic.dy.fi Git - linux-stable/commitdiff
io_uring: don't guard IORING_OFF_PBUF_RING with SETUP_NO_MMAP
authorJens Axboe <axboe@kernel.dk>
Tue, 28 Nov 2023 00:08:19 +0000 (17:08 -0700)
committerJens Axboe <axboe@kernel.dk>
Tue, 28 Nov 2023 00:10:56 +0000 (17:10 -0700)
This flag only applies to the SQ and CQ rings, it's perfectly valid
to use a mmap approach for the provided ring buffers. Move the
check into where it belongs.

Cc: stable@vger.kernel.org
Fixes: 03d89a2de25b ("io_uring: support for user allocated memory for rings/sqes")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/io_uring.c

index b45abfd75415d3c6db9d0e7cc28a4c62f62915c7..52e4b14ad8aab4e1167172cd6f66edf150f7ec5c 100644 (file)
@@ -3478,16 +3478,18 @@ static void *io_uring_validate_mmap_request(struct file *file,
        struct page *page;
        void *ptr;
 
-       /* Don't allow mmap if the ring was setup without it */
-       if (ctx->flags & IORING_SETUP_NO_MMAP)
-               return ERR_PTR(-EINVAL);
-
        switch (offset & IORING_OFF_MMAP_MASK) {
        case IORING_OFF_SQ_RING:
        case IORING_OFF_CQ_RING:
+               /* Don't allow mmap if the ring was setup without it */
+               if (ctx->flags & IORING_SETUP_NO_MMAP)
+                       return ERR_PTR(-EINVAL);
                ptr = ctx->rings;
                break;
        case IORING_OFF_SQES:
+               /* Don't allow mmap if the ring was setup without it */
+               if (ctx->flags & IORING_SETUP_NO_MMAP)
+                       return ERR_PTR(-EINVAL);
                ptr = ctx->sq_sqes;
                break;
        case IORING_OFF_PBUF_RING: {