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: Move checking GENHD_FL_NO_PART to bdev_add_partition()

Commit 1a721de8489f ("block: don't add or resize partition on the disk
with GENHD_FL_NO_PART") prevented all operations about partitions on disks
with GENHD_FL_NO_PART in blkpg_do_ioctl() since they are meaningless.
However, it changed error code in some scenarios. So move checking
GENHD_FL_NO_PART to bdev_add_partition() to eliminate impact.

Fixes: 1a721de8489f ("block: don't add or resize partition on the disk with GENHD_FL_NO_PART")
Reported-by: Allison Karlitskaya <allison.karlitskaya@redhat.com>
Closes: https://lore.kernel.org/all/CAOYeF9VsmqKMcQjo1k6YkGNujwN-nzfxY17N3F-CMikE1tYp+w@mail.gmail.com/
Signed-off-by: Li Lingfeng <lilingfeng3@huawei.com>
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
Link: https://lore.kernel.org/r/20240118130401.792757-1-lilingfeng@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Li Lingfeng and committed by
Jens Axboe
7777f47f 6613476e

+5 -2
-2
block/ioctl.c
··· 20 20 struct blkpg_partition p; 21 21 sector_t start, length; 22 22 23 - if (disk->flags & GENHD_FL_NO_PART) 24 - return -EINVAL; 25 23 if (!capable(CAP_SYS_ADMIN)) 26 24 return -EACCES; 27 25 if (copy_from_user(&p, upart, sizeof(struct blkpg_partition)))
+5
block/partitions/core.c
··· 439 439 goto out; 440 440 } 441 441 442 + if (disk->flags & GENHD_FL_NO_PART) { 443 + ret = -EINVAL; 444 + goto out; 445 + } 446 + 442 447 if (partition_overlaps(disk, start, length, -1)) { 443 448 ret = -EBUSY; 444 449 goto out;