From: Jens Axboe Date: Fri, 18 Mar 2022 17:28:13 +0000 (-0600) Subject: io_uring: terminate manual loop iterator loop correctly for non-vecs X-Git-Tag: v6.1-rc5~1632^2~19 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5e929367468c8f97cd1ffb0417316cecfebef94b;p=platform%2Fkernel%2Flinux-starfive.git io_uring: terminate manual loop iterator loop correctly for non-vecs The fix for not advancing the iterator if we're using fixed buffers is broken in that it can hit a condition where we don't terminate the loop. This results in io-wq looping forever, asking to read (or write) 0 bytes for every subsequent loop. Reported-by: Joel Jaeschke Link: https://github.com/axboe/liburing/issues/549 Fixes: 16c8d2df7ec0 ("io_uring: ensure symmetry in handling iter types in loop_rw_iter()") Signed-off-by: Jens Axboe --- diff --git a/fs/io_uring.c b/fs/io_uring.c index 2d6ab73..5fa7363 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -3612,13 +3612,15 @@ static ssize_t loop_rw_iter(int rw, struct io_kiocb *req, struct iov_iter *iter) ret = nr; break; } + ret += nr; if (!iov_iter_is_bvec(iter)) { iov_iter_advance(iter, nr); } else { - req->rw.len -= nr; req->rw.addr += nr; + req->rw.len -= nr; + if (!req->rw.len) + break; } - ret += nr; if (nr != iovec.iov_len) break; }