Patch "block: fix wrong mode for blkdev_put() from disk_scan_partitions()" has been added to the 6.2-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 wrong mode for blkdev_put() from disk_scan_partitions()

to the 6.2-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-wrong-mode-for-blkdev_put-from-disk_scan_p.patch
and it can be found in the queue-6.2 subdirectory.

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



commit 8db956c5305a97eaa34e88be38f8d9d913c8dfa9
Author: Yu Kuai <yukuai3@xxxxxxxxxx>
Date:   Tue Mar 7 18:55:52 2023 +0800

    block: fix wrong mode for blkdev_put() from disk_scan_partitions()
    
    [ Upstream commit 428913bce1e67ccb4dae317fd0332545bf8c9233 ]
    
    If disk_scan_partitions() is called with 'FMODE_EXCL',
    blkdev_get_by_dev() will be called without 'FMODE_EXCL', however, follow
    blkdev_put() is still called with 'FMODE_EXCL', which will cause
    'bd_holders' counter to leak.
    
    Fix the problem by using the right mode for blkdev_put().
    
    Reported-by: syzbot+2bcc0d79e548c4f62a59@xxxxxxxxxxxxxxxxxxxxxxxxx
    Link: https://lore.kernel.org/lkml/f9649d501bc8c3444769418f6c26263555d9d3be.camel@xxxxxxxxxxxxx/T/
    Tested-by: Julian Ruess <julianr@xxxxxxxxxxxxx>
    Fixes: e5cfefa97bcc ("block: fix scan partition for exclusively open device again")
    Signed-off-by: Yu Kuai <yukuai3@xxxxxxxxxx>
    Reviewed-by: Jan Kara <jack@xxxxxxx>
    Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/block/genhd.c b/block/genhd.c
index 6cdaeb7169004..9c4c9aa559ab8 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -385,7 +385,7 @@ int disk_scan_partitions(struct gendisk *disk, fmode_t mode)
 	if (IS_ERR(bdev))
 		ret =  PTR_ERR(bdev);
 	else
-		blkdev_put(bdev, mode);
+		blkdev_put(bdev, mode & ~FMODE_EXCL);
 
 	if (!(mode & FMODE_EXCL))
 		bd_abort_claiming(disk->part0, disk_scan_partitions);



[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