From: Li Lingfeng Date: Thu, 31 Aug 2023 07:59:00 +0000 (+0800) Subject: block: don't add or resize partition on the disk with GENHD_FL_NO_PART X-Git-Tag: v6.6-rc1~18^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1a721de8489f;p=thirdparty%2Flinux.git block: don't add or resize partition on the disk with GENHD_FL_NO_PART Commit a33df75c6328 ("block: use an xarray for disk->part_tbl") remove disk_expand_part_tbl() in add_partition(), which means all kinds of devices will support extended dynamic `dev_t`. However, some devices with GENHD_FL_NO_PART are not expected to add or resize partition. Fix this by adding check of GENHD_FL_NO_PART before add or resize partition. Fixes: a33df75c6328 ("block: use an xarray for disk->part_tbl") Signed-off-by: Li Lingfeng Reviewed-by: Christoph Hellwig Link: https://lore.kernel.org/r/20230831075900.1725842-1-lilingfeng@huaweicloud.com Signed-off-by: Jens Axboe --- diff --git a/block/ioctl.c b/block/ioctl.c index 648670ddb164a..d5f5cd61efd7f 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -20,6 +20,8 @@ static int blkpg_do_ioctl(struct block_device *bdev, struct blkpg_partition p; long long start, length; + if (disk->flags & GENHD_FL_NO_PART) + return -EINVAL; if (!capable(CAP_SYS_ADMIN)) return -EACCES; if (copy_from_user(&p, upart, sizeof(struct blkpg_partition)))