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

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



commit 2e7ea35199c93dd109d423d01df89db12efc1732
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 6aef540bbacf..84f5ac627e79 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -421,7 +421,9 @@ int 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)
 			return -EINVAL;
 	} 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