Commit 6f007b14 authored by Jens Axboe's avatar Jens Axboe

io_uring: don't guard IORING_OFF_PBUF_RING with SETUP_NO_MMAP

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: 03d89a2d ("io_uring: support for user allocated memory for rings/sqes")
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 820d070f
...@@ -3478,16 +3478,18 @@ static void *io_uring_validate_mmap_request(struct file *file, ...@@ -3478,16 +3478,18 @@ static void *io_uring_validate_mmap_request(struct file *file,
struct page *page; struct page *page;
void *ptr; 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) { switch (offset & IORING_OFF_MMAP_MASK) {
case IORING_OFF_SQ_RING: case IORING_OFF_SQ_RING:
case IORING_OFF_CQ_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; ptr = ctx->rings;
break; break;
case IORING_OFF_SQES: 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; ptr = ctx->sq_sqes;
break; break;
case IORING_OFF_PBUF_RING: { case IORING_OFF_PBUF_RING: {
......
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