Commit 5044d07a authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Greg Kroah-Hartman

io_uring: NULL-deref for IOSQE_{ASYNC,DRAIN}

[ Upstream commit f1d96a8f ]

Processing links, io_submit_sqe() prepares requests, drops sqes, and
passes them with sqe=NULL to io_queue_sqe(). There IOSQE_DRAIN and/or
IOSQE_ASYNC requests will go through the same prep, which doesn't expect
sqe=NULL and fail with NULL pointer deference.

Always do full prepare including io_alloc_async_ctx() for linked
requests, and then it can skip the second preparation.

Cc: [email protected] # 5.5
Signed-off-by: default avatarPavel Begunkov <[email protected]>
Signed-off-by: default avatarJens Axboe <[email protected]>
Signed-off-by: default avatarSasha Levin <[email protected]>
parent 873f1841
......@@ -3098,6 +3098,9 @@ static int io_req_defer_prep(struct io_kiocb *req,
ssize_t ret = 0;
if (!sqe)
return 0;
switch (req->opcode) {
......@@ -3681,6 +3684,11 @@ static bool io_submit_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
req->flags |= REQ_F_HARDLINK;
if (io_alloc_async_ctx(req)) {
ret = -EAGAIN;
goto err_req;
ret = io_req_defer_prep(req, sqe);
if (ret)
req->flags |= REQ_F_FAIL_LINK;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment