Skip to content

Commit 5d204bc

Browse files
committed
io_uring: don't map read/write iovec potentially twice
If we have a read/write that is deferred, we already setup the async IO context for that request, and mapped it. When we later try and execute the request and we get -EAGAIN, we don't want to attempt to re-map it. If we do, we end up with garbage in the iovec, which typically leads to an -EFAULT or -EINVAL completion. Cc: [email protected] # 5.5 Reported-by: Dan Melnic <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 0b7b21e commit 5d204bc

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

fs/io_uring.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2171,10 +2171,12 @@ static int io_setup_async_rw(struct io_kiocb *req, ssize_t io_size,
21712171
{
21722172
if (!io_op_defs[req->opcode].async_ctx)
21732173
return 0;
2174-
if (!req->io && io_alloc_async_ctx(req))
2175-
return -ENOMEM;
2174+
if (!req->io) {
2175+
if (io_alloc_async_ctx(req))
2176+
return -ENOMEM;
21762177

2177-
io_req_map_rw(req, io_size, iovec, fast_iov, iter);
2178+
io_req_map_rw(req, io_size, iovec, fast_iov, iter);
2179+
}
21782180
req->work.func = io_rw_async;
21792181
return 0;
21802182
}

0 commit comments

Comments
 (0)