Skip to content

Commit ab0ac09

Browse files
isilenceaxboe
authored andcommitted
io_uring: fix invalid flags for io_put_kbuf()
io_req_complete_failed() doesn't require callers to hold ->uring_lock, use IO_URING_F_UNLOCKED version of io_put_kbuf(). The only affected place is the fail path of io_apoll_task_func(). Also add a lockdep annotation to catch such bugs in the future. Fixes: 3b2b78a ("io_uring: extend provided buf return to fails") Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/ccf602dbf8df3b6a8552a262d8ee0a13a086fbc7.1648212967.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 41cdcc2 commit ab0ac09

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

fs/io_uring.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1370,6 +1370,8 @@ static inline unsigned int io_put_kbuf(struct io_kiocb *req,
13701370
cflags = __io_put_kbuf(req, &ctx->io_buffers_comp);
13711371
spin_unlock(&ctx->completion_lock);
13721372
} else {
1373+
lockdep_assert_held(&req->ctx->uring_lock);
1374+
13731375
cflags = __io_put_kbuf(req, &req->ctx->io_buffers_cache);
13741376
}
13751377

@@ -2165,7 +2167,7 @@ static inline void io_req_complete(struct io_kiocb *req, s32 res)
21652167
static void io_req_complete_failed(struct io_kiocb *req, s32 res)
21662168
{
21672169
req_set_fail(req);
2168-
io_req_complete_post(req, res, io_put_kbuf(req, 0));
2170+
io_req_complete_post(req, res, io_put_kbuf(req, IO_URING_F_UNLOCKED));
21692171
}
21702172

21712173
static void io_req_complete_fail_submit(struct io_kiocb *req)

0 commit comments

Comments
 (0)