Skip to content

Commit f1d96a8

Browse files
isilenceaxboe
authored andcommitted
io_uring: NULL-deref for IOSQE_{ASYNC,DRAIN}
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: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 805b13a commit f1d96a8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

fs/io_uring.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4131,6 +4131,9 @@ static int io_req_defer_prep(struct io_kiocb *req,
41314131
{
41324132
ssize_t ret = 0;
41334133

4134+
if (!sqe)
4135+
return 0;
4136+
41344137
if (io_op_defs[req->opcode].file_table) {
41354138
ret = io_grab_files(req);
41364139
if (unlikely(ret))
@@ -4907,6 +4910,11 @@ static bool io_submit_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe,
49074910
if (sqe_flags & (IOSQE_IO_LINK|IOSQE_IO_HARDLINK)) {
49084911
req->flags |= REQ_F_LINK;
49094912
INIT_LIST_HEAD(&req->link_list);
4913+
4914+
if (io_alloc_async_ctx(req)) {
4915+
ret = -EAGAIN;
4916+
goto err_req;
4917+
}
49104918
ret = io_req_defer_prep(req, sqe);
49114919
if (ret)
49124920
req->flags |= REQ_F_FAIL_LINK;

0 commit comments

Comments
 (0)