Patch "io_uring/rw: ensure io->bytes_done is always initialized" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    io_uring/rw: ensure io->bytes_done is always initialized

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     io_uring-rw-ensure-io-bytes_done-is-always-initialized.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.


>From 0a535eddbe0dc1de4386046ab849f08aeb2f8faf Mon Sep 17 00:00:00 2001
From: Jens Axboe <axboe@xxxxxxxxx>
Date: Thu, 21 Dec 2023 08:49:18 -0700
Subject: io_uring/rw: ensure io->bytes_done is always initialized

From: Jens Axboe <axboe@xxxxxxxxx>

commit 0a535eddbe0dc1de4386046ab849f08aeb2f8faf upstream.

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@xxxxxxxxxxxxxxx
Reported-by: xingwei lee <xrivendell7@xxxxxxxxx>
Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 io_uring/rw.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -534,15 +534,19 @@ static inline int io_rw_prep_async(struc
 	struct iovec *iov;
 	int ret;
 
+	iorw->bytes_done = 0;
+	iorw->free_iovec = NULL;
+
 	/* submission path, ->uring_lock should already be taken */
 	ret = io_import_iovec(rw, req, &iov, &iorw->s, 0);
 	if (unlikely(ret < 0))
 		return ret;
 
-	iorw->bytes_done = 0;
-	iorw->free_iovec = iov;
-	if (iov)
+	if (iov) {
+		iorw->free_iovec = iov;
 		req->flags |= REQ_F_NEED_CLEANUP;
+	}
+
 	return 0;
 }
 


Patches currently in stable-queue which might be from axboe@xxxxxxxxx are

queue-6.1/block-fix-iterating-over-an-empty-bio-with-bio_for_each_folio_all.patch
queue-6.1/null_blk-don-t-cap-max_hw_sectors-to-blk_def_max_sec.patch
queue-6.1/block-add-check-of-minors-and-first_minor-in-device_.patch
queue-6.1/io_uring-rw-ensure-io-bytes_done-is-always-initialized.patch
queue-6.1/md-raid1-use-blk_opf_t-for-read-and-write-operations.patch
queue-6.1/block-make-blk_def_max_sectors-unsigned.patch
queue-6.1/block-set-memalloc_noio-to-false-on-device_add_disk-.patch
queue-6.1/scsi-target-core-add-missing-file_-start-end-_write.patch
queue-6.1/block-add-check-that-partition-length-needs-to-be-aligned-with-block-size.patch




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux