Patch "block: add check of 'minors' and 'first_minor' in device_add_disk()" has been added to the 6.7-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: add check of 'minors' and 'first_minor' in device_add_disk()

to the 6.7-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-add-check-of-minors-and-first_minor-in-device_.patch
and it can be found in the queue-6.7 subdirectory.

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



commit 9ed0e620fb8cac81aecf62f2db1650ed81d875d1
Author: Li Nan <linan122@xxxxxxxxxx>
Date:   Tue Dec 19 15:59:42 2023 +0800

    block: add check of 'minors' and 'first_minor' in device_add_disk()
    
    [ Upstream commit 4c434392c4777881d01beada6701eff8c76b43fe ]
    
    'first_minor' represents the starting minor number of disks, and
    'minors' represents the number of partitions in the device. Neither
    of them can be greater than MINORMASK + 1.
    
    Commit e338924bd05d ("block: check minor range in device_add_disk()")
    only added the check of 'first_minor + minors'. However, their sum might
    be less than MINORMASK but their values are wrong. Complete the checks now.
    
    Fixes: e338924bd05d ("block: check minor range in device_add_disk()")
    Signed-off-by: Li Nan <linan122@xxxxxxxxxx>
    Reviewed-by: Christoph Hellwig <hch@xxxxxx>
    Link: https://lore.kernel.org/r/20231219075942.840255-1-linan666@xxxxxxxxxxxxxxx
    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 13db3a7943d8..d74fb5b4ae68 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -432,7 +432,9 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk,
 				DISK_MAX_PARTS);
 			disk->minors = DISK_MAX_PARTS;
 		}
-		if (disk->first_minor + disk->minors > MINORMASK + 1)
+		if (disk->first_minor > MINORMASK ||
+		    disk->minors > MINORMASK + 1 ||
+		    disk->first_minor + disk->minors > MINORMASK + 1)
 			goto out_exit_elevator;
 	} else {
 		if (WARN_ON(disk->minors))




[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