Skip to content

Commit

Permalink
io_uring: don't re-read sqe->off in timeout_prep()
Browse files Browse the repository at this point in the history
SQEs are user writable, don't read sqe->off twice in io_timeout_prep()

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Pavel Begunkov authored and Jens Axboe committed May 26, 2020
1 parent 733f5c9 commit 56080b0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fs/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -4803,18 +4803,19 @@ static int io_timeout_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe,
{
struct io_timeout_data *data;
unsigned flags;
u32 off = READ_ONCE(sqe->off);

if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
return -EINVAL;
if (sqe->ioprio || sqe->buf_index || sqe->len != 1)
return -EINVAL;
if (sqe->off && is_timeout_link)
if (off && is_timeout_link)
return -EINVAL;
flags = READ_ONCE(sqe->timeout_flags);
if (flags & ~IORING_TIMEOUT_ABS)
return -EINVAL;

req->timeout.count = READ_ONCE(sqe->off);
req->timeout.count = off;

if (!req->io && io_alloc_async_ctx(req))
return -ENOMEM;
Expand Down

0 comments on commit 56080b0

Please sign in to comment.