Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

block: add check of 'minors' and 'first_minor' in device_add_disk()

'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@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20231219075942.840255-1-linan666@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Li Nan and committed by
Jens Axboe
4c434392 6c9b9708

+3 -1
+3 -1
block/genhd.c
··· 432 432 DISK_MAX_PARTS); 433 433 disk->minors = DISK_MAX_PARTS; 434 434 } 435 - if (disk->first_minor + disk->minors > MINORMASK + 1) 435 + if (disk->first_minor > MINORMASK || 436 + disk->minors > MINORMASK + 1 || 437 + disk->first_minor + disk->minors > MINORMASK + 1) 436 438 goto out_exit_elevator; 437 439 } else { 438 440 if (WARN_ON(disk->minors))