Skip to content

Commit 4eb8dde

Browse files
committed
io_uring: fix openat/openat2 unified prep handling
A previous commit unified how we handle prep for these two functions, but this means that we check the allowed context (SQPOLL, specifically) later than we should. Move the ring type checking into the two parent functions, instead of doing it after we've done some setup work. Fixes: ec65fea ("io_uring: deduplicate io_openat{,2}_prep()") Reported-by: Andy Lutomirski <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 6ca56f8 commit 4eb8dde

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/io_uring.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3527,8 +3527,6 @@ static int __io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe
35273527
const char __user *fname;
35283528
int ret;
35293529

3530-
if (unlikely(req->ctx->flags & (IORING_SETUP_IOPOLL|IORING_SETUP_SQPOLL)))
3531-
return -EINVAL;
35323530
if (unlikely(sqe->ioprio || sqe->buf_index))
35333531
return -EINVAL;
35343532
if (unlikely(req->flags & REQ_F_FIXED_FILE))
@@ -3555,6 +3553,8 @@ static int io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
35553553
{
35563554
u64 flags, mode;
35573555

3556+
if (unlikely(req->ctx->flags & (IORING_SETUP_IOPOLL|IORING_SETUP_SQPOLL)))
3557+
return -EINVAL;
35583558
if (req->flags & REQ_F_NEED_CLEANUP)
35593559
return 0;
35603560
mode = READ_ONCE(sqe->len);
@@ -3569,6 +3569,8 @@ static int io_openat2_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
35693569
size_t len;
35703570
int ret;
35713571

3572+
if (unlikely(req->ctx->flags & (IORING_SETUP_IOPOLL|IORING_SETUP_SQPOLL)))
3573+
return -EINVAL;
35723574
if (req->flags & REQ_F_NEED_CLEANUP)
35733575
return 0;
35743576
how = u64_to_user_ptr(READ_ONCE(sqe->addr2));

0 commit comments

Comments
 (0)