hi, After looking into more codes, I guess there will be more races between REQ_F_NEED_CLEANUP and io_complete_rw_iopoll/io_complete_rw. In the end of io_read() or io_write(), there are such below codes: req->flags &= ~REQ_F_NEED_CLEANUP; kfree(iovec); return ret; When "req->flags &= ~REQ_F_NEED_CLEANUP" is executed, io request may also have been completed, then there will be many req->flags modifications called by io_complete_rw_iopoll() or io_complete_rw(), such as req_set_fail_links(req), req->flags |= REQ_F_OVERFLOW in __io_cqring_fill_event(). All these races can introduce severe bugs. I wonder below patch whether can fix these races: diff --git a/fs/io_uring.c b/fs/io_uring.c index 13e24a6137d5..3bab6b414864 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -2654,8 +2654,8 @@ static int io_read(struct io_kiocb *req, bool force_nonblock) } } out_free: - kfree(iovec); - req->flags &= ~REQ_F_NEED_CLEANUP; + if (!(req->flags & REQ_F_NEED_CLEANUP)) + kfree(iovec); return ret; } If REQ_F_NEED_CLEANUP is set, we always make __io_req_aux_free() do the cleanup work. Regards, Xiaoguang Wang