summaryrefslogtreecommitdiffstats
path: root/io_uring/io_uring.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2023-11-27 17:08:19 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-12-08 08:52:19 +0100
commitb797b7f83e537875cf22b89f673baee492407589 (patch)
tree0dd79caa3a35e1a739fdcd2afcbe1a519eb8e67f /io_uring/io_uring.c
parent5f1a233efee8f4c98985210e54f0746d7d6ade17 (diff)
downloadlinux-stable-b797b7f83e537875cf22b89f673baee492407589.tar.gz
linux-stable-b797b7f83e537875cf22b89f673baee492407589.tar.bz2
linux-stable-b797b7f83e537875cf22b89f673baee492407589.zip
io_uring: don't guard IORING_OFF_PBUF_RING with SETUP_NO_MMAP
commit 6f007b1406637d3d73d42e41d7e8d9b245185e69 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'io_uring/io_uring.c')
-rw-r--r--io_uring/io_uring.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index efd53316be6b..5570c155128f 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -3436,16 +3436,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: {