提交 5de74714 编写于 作者: J Jens Axboe 提交者: Zheng Zengkai

io_uring: terminate manual loop iterator loop correctly for non-vecs

stable inclusion
from stable-v5.10.110
commit 509565faed7e6a4d27b9df2b8f7ffeedae0067aa
bugzilla: https://gitee.com/openeuler/kernel/issues/I574AL

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=509565faed7e6a4d27b9df2b8f7ffeedae0067aa

--------------------------------

[ Upstream commit 5e929367 ]

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: NJoel Jaeschke <joel.jaeschke@gmail.com>
Link: https://github.com/axboe/liburing/issues/549
Fixes: 16c8d2df ("io_uring: ensure symmetry in handling iter types in loop_rw_iter()")
Signed-off-by: NJens Axboe <axboe@kernel.dk>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYu Liao <liaoyu15@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 cfada097
......@@ -3182,13 +3182,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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册