diff options
| author | Li Lingfeng <lilingfeng3@huawei.com> | 2023-08-31 15:59:00 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-09-19 12:23:03 +0200 |
| commit | 072cd213c64f0c776e3835061c2c1d22a4776cd0 (patch) | |
| tree | d7f94abcda38a1c382833e9e272532caca24720f /block/ioctl.c | |
| parent | c6ce1c5dd32729c707357dc08eb17050d4073c03 (diff) | |
| download | linux-072cd213c64f0c776e3835061c2c1d22a4776cd0.tar.gz linux-072cd213c64f0c776e3835061c2c1d22a4776cd0.tar.bz2 linux-072cd213c64f0c776e3835061c2c1d22a4776cd0.zip | |
block: don't add or resize partition on the disk with GENHD_FL_NO_PART
[ Upstream commit 1a721de8489fa559ff4471f73c58bb74ac5580d3 ]
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 <lilingfeng3@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20230831075900.1725842-1-lilingfeng@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'block/ioctl.c')
| -rw-r--r-- | block/ioctl.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/block/ioctl.c b/block/ioctl.c index cd506a902963..8f39e413f12a 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))) |
