]> git.itanic.dy.fi Git - linux-stable/commit
io_uring/rw: ensure io->bytes_done is always initialized
authorJens Axboe <axboe@kernel.dk>
Thu, 21 Dec 2023 15:49:18 +0000 (08:49 -0700)
committerJens Axboe <axboe@kernel.dk>
Thu, 21 Dec 2023 15:49:18 +0000 (08:49 -0700)
commit0a535eddbe0dc1de4386046ab849f08aeb2f8faf
treec15ad68745ed65233477ea63047a778727ff54a0
parent6e5e6d274956305f1fc0340522b38f5f5be74bdb
io_uring/rw: ensure io->bytes_done is always initialized

If IOSQE_ASYNC is set and we fail importing an iovec for a readv or
writev request, then we leave ->bytes_done uninitialized and hence the
eventual failure CQE posted can potentially have a random res value
rather than the expected -EINVAL.

Setup ->bytes_done before potentially failing, so we have a consistent
value if we fail the request early.

Cc: stable@vger.kernel.org
Reported-by: xingwei lee <xrivendell7@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/rw.c