Patch "block: Fix WARNING in _copy_from_iter" has been added to the 6.6-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

    block: Fix WARNING in _copy_from_iter

to the 6.6-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:
     block-fix-warning-in-_copy_from_iter.patch
and it can be found in the queue-6.6 subdirectory.

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



commit e08216397c09b35168ebdc0d87557b7c660450f9
Author: Christian A. Ehrhardt <lk@xxxxxxx>
Date:   Sun Jan 21 21:26:34 2024 +0100

    block: Fix WARNING in _copy_from_iter
    
    [ Upstream commit 13f3956eb5681a4045a8dfdef48df5dc4d9f58a6 ]
    
    Syzkaller reports a warning in _copy_from_iter because an
    iov_iter is supposedly used in the wrong direction. The reason
    is that syzcaller managed to generate a request with
    a transfer direction of SG_DXFER_TO_FROM_DEV. This instructs
    the kernel to copy user buffers into the kernel, read into
    the copied buffers and then copy the data back to user space.
    
    Thus the iovec is used in both directions.
    
    Detect this situation in the block layer and construct a new
    iterator with the correct direction for the copy-in.
    
    Reported-by: syzbot+a532b03fdfee2c137666@xxxxxxxxxxxxxxxxxxxxxxxxx
    Closes: https://lore.kernel.org/lkml/0000000000009b92c10604d7a5e9@xxxxxxxxxx/t/
    Reported-by: syzbot+63dec323ac56c28e644f@xxxxxxxxxxxxxxxxxxxxxxxxx
    Closes: https://lore.kernel.org/lkml/0000000000003faaa105f6e7c658@xxxxxxxxxx/T/
    Signed-off-by: Christian A. Ehrhardt <lk@xxxxxxx>
    Reviewed-by: Christoph Hellwig <hch@xxxxxx>
    Link: https://lore.kernel.org/r/20240121202634.275068-1-lk@xxxxxxx
    Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/block/blk-map.c b/block/blk-map.c
index 8584babf3ea0c..71210cdb34426 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -205,12 +205,19 @@ static int bio_copy_user_iov(struct request *rq, struct rq_map_data *map_data,
 	/*
 	 * success
 	 */
-	if ((iov_iter_rw(iter) == WRITE &&
-	     (!map_data || !map_data->null_mapped)) ||
-	    (map_data && map_data->from_user)) {
+	if (iov_iter_rw(iter) == WRITE &&
+	     (!map_data || !map_data->null_mapped)) {
 		ret = bio_copy_from_iter(bio, iter);
 		if (ret)
 			goto cleanup;
+	} else if (map_data && map_data->from_user) {
+		struct iov_iter iter2 = *iter;
+
+		/* This is the copy-in part of SG_DXFER_TO_FROM_DEV. */
+		iter2.data_source = ITER_SOURCE;
+		ret = bio_copy_from_iter(bio, &iter2);
+		if (ret)
+			goto cleanup;
 	} else {
 		if (bmd->is_our_pages)
 			zero_fill_bio(bio);




[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