* [PATCH] block: don't add or resize partition on the disk with GENHD_FL_NO_PART
@ 2023-08-31 7:59 Li Lingfeng
2023-08-31 12:42 ` Christoph Hellwig
2023-08-31 15:22 ` Jens Axboe
0 siblings, 2 replies; 3+ messages in thread
From: Li Lingfeng @ 2023-08-31 7:59 UTC (permalink / raw)
To: linux-block
Cc: hch, axboe, tj, yukuai1, houtao1, yi.zhang, yangerkun, lilingfeng
From: Li Lingfeng <lilingfeng3@huawei.com>
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>
---
block/ioctl.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/block/ioctl.c b/block/ioctl.c
index 648670ddb164..d5f5cd61efd7 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)))
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] block: don't add or resize partition on the disk with GENHD_FL_NO_PART
2023-08-31 7:59 [PATCH] block: don't add or resize partition on the disk with GENHD_FL_NO_PART Li Lingfeng
@ 2023-08-31 12:42 ` Christoph Hellwig
2023-08-31 15:22 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2023-08-31 12:42 UTC (permalink / raw)
To: Li Lingfeng
Cc: linux-block, hch, axboe, tj, yukuai1, houtao1, yi.zhang,
yangerkun
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] block: don't add or resize partition on the disk with GENHD_FL_NO_PART
2023-08-31 7:59 [PATCH] block: don't add or resize partition on the disk with GENHD_FL_NO_PART Li Lingfeng
2023-08-31 12:42 ` Christoph Hellwig
@ 2023-08-31 15:22 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2023-08-31 15:22 UTC (permalink / raw)
To: linux-block, Li Lingfeng; +Cc: hch, tj, yukuai1, houtao1, yi.zhang, yangerkun
On Thu, 31 Aug 2023 15:59:00 +0800, Li Lingfeng wrote:
> 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.
>
> [...]
Applied, thanks!
[1/1] block: don't add or resize partition on the disk with GENHD_FL_NO_PART
(no commit info)
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-31 15:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-31 7:59 [PATCH] block: don't add or resize partition on the disk with GENHD_FL_NO_PART Li Lingfeng
2023-08-31 12:42 ` Christoph Hellwig
2023-08-31 15:22 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox