Skip to content

Commit d090bff

Browse files
committed
io_uring/memmap: explicitly return -EFAULT for mmap on NULL rings
The later mapping will actually check this too, but in terms of code clarify, explicitly check for whether or not the rings and sqes are valid during validation. That makes it explicit that if they are non-NULL, they are valid and can get mapped. Signed-off-by: Jens Axboe <[email protected]>
1 parent 81d8191 commit d090bff

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

io_uring/memmap.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,15 @@ static void *io_uring_validate_mmap_request(struct file *file, loff_t pgoff,
204204
/* Don't allow mmap if the ring was setup without it */
205205
if (ctx->flags & IORING_SETUP_NO_MMAP)
206206
return ERR_PTR(-EINVAL);
207+
if (!ctx->rings)
208+
return ERR_PTR(-EFAULT);
207209
return ctx->rings;
208210
case IORING_OFF_SQES:
209211
/* Don't allow mmap if the ring was setup without it */
210212
if (ctx->flags & IORING_SETUP_NO_MMAP)
211213
return ERR_PTR(-EINVAL);
214+
if (!ctx->sq_sqes)
215+
return ERR_PTR(-EFAULT);
212216
return ctx->sq_sqes;
213217
case IORING_OFF_PBUF_RING: {
214218
struct io_buffer_list *bl;

0 commit comments

Comments
 (0)