mirror of https://gitee.com/openkylin/linux.git
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: ec65fea5a8
("io_uring: deduplicate io_openat{,2}_prep()")
Reported-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
6ca56f8459
commit
4eb8dded6b
|
@ -3527,8 +3527,6 @@ static int __io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe
|
|||
const char __user *fname;
|
||||
int ret;
|
||||
|
||||
if (unlikely(req->ctx->flags & (IORING_SETUP_IOPOLL|IORING_SETUP_SQPOLL)))
|
||||
return -EINVAL;
|
||||
if (unlikely(sqe->ioprio || sqe->buf_index))
|
||||
return -EINVAL;
|
||||
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)
|
|||
{
|
||||
u64 flags, mode;
|
||||
|
||||
if (unlikely(req->ctx->flags & (IORING_SETUP_IOPOLL|IORING_SETUP_SQPOLL)))
|
||||
return -EINVAL;
|
||||
if (req->flags & REQ_F_NEED_CLEANUP)
|
||||
return 0;
|
||||
mode = READ_ONCE(sqe->len);
|
||||
|
@ -3569,6 +3569,8 @@ static int io_openat2_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
|
|||
size_t len;
|
||||
int ret;
|
||||
|
||||
if (unlikely(req->ctx->flags & (IORING_SETUP_IOPOLL|IORING_SETUP_SQPOLL)))
|
||||
return -EINVAL;
|
||||
if (req->flags & REQ_F_NEED_CLEANUP)
|
||||
return 0;
|
||||
how = u64_to_user_ptr(READ_ONCE(sqe->addr2));
|
||||
|
|
Loading…
Reference in New Issue