From: Christoph Hellwig hch@lst.de
mainline inclusion from mainline-v5.12~10 commit 68e6582e8f2dc32fd2458b9926564faa1fb4560e category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I7F3M1 CVE: NA
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h...
----------------------------------------------
The switch to go through blkdev_get_by_dev means we now ignore the return value from bdev_disk_changed in __blkdev_get. Add a manual check to restore the old semantics.
Fixes: 4601b4b130de ("block: reopen the device in blkdev_reread_part") Reported-by: Karel Zak kzak@redhat.com Signed-off-by: Christoph Hellwig hch@lst.de Link: https://lore.kernel.org/r/20210421160502.447418-1-hch@lst.de Signed-off-by: Jens Axboe axboe@kernel.dk
Conflicts: block/ioctl.c Signed-off-by: Li Lingfeng lilingfeng3@huawei.com Reviewed-by: Yu Kuai yukuai3@huawei.com Signed-off-by: Yongqiang Liu liuyongqiang13@huawei.com --- block/ioctl.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/block/ioctl.c b/block/ioctl.c index e5da2482342a..9d0eeb1b0bbd 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -79,6 +79,8 @@ int __blkdev_reread_part(struct block_device *bdev) return -EINVAL; if (!capable(CAP_SYS_ADMIN)) return -EACCES; + if (bdev->bd_part_count) + return -EBUSY;
lockdep_assert_held(&bdev->bd_mutex);
@@ -503,6 +505,8 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, return -EACCES; if (bdev != bdev->bd_contains) return -EINVAL; + if (bdev->bd_part_count) + return -EBUSY; return disk_scan_partitions(bdev->bd_disk, mode); case BLKGETSIZE: size = i_size_read(bdev->bd_inode);