mirror of https://gitee.com/openkylin/linux.git
block: don't create too many partitions
Commita33df75c63
("block: use an xarray for disk->part_tbl") drops the check on max supported number of partitionsr, and allows partition with bigger partition numbers to be added. However, ->bd_partno is defined as u8, so partition index of xarray table may not match with ->bd_partno. Then delete_partition() may delete one unmatched partition, and caused use-after-free. Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reported-by: syzbot+8fede7e30c7cee0de139@syzkaller.appspotmail.com Fixes:a33df75c63
("block: use an xarray for disk->part_tbl") Signed-off-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
7de55b7d6f
commit
e82fc78557
|
@ -322,6 +322,13 @@ static struct block_device *add_partition(struct gendisk *disk, int partno,
|
||||||
const char *dname;
|
const char *dname;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* disk_max_parts() won't be zero, either GENHD_FL_EXT_DEVT is set
|
||||||
|
* or 'minors' is passed to alloc_disk().
|
||||||
|
*/
|
||||||
|
if (partno >= disk_max_parts(disk))
|
||||||
|
return ERR_PTR(-EINVAL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Partitions are not supported on zoned block devices that are used as
|
* Partitions are not supported on zoned block devices that are used as
|
||||||
* such.
|
* such.
|
||||||
|
|
Loading…
Reference in New Issue