Skip to content

Commit 985958b

Browse files
YuKuai-huaweiaxboe
authored andcommitted
block: fix wrong mode for blkdev_get_by_dev() from disk_scan_partitions()
After commit 2736e8e ("block: use the holder as indication for exclusive opens"), blkdev_get_by_dev() will warn if holder is NULL and mode contains 'FMODE_EXCL'. holder from blkdev_get_by_dev() from disk_scan_partitions() is always NULL, hence it should not use 'FMODE_EXCL', which is broben by the commit. For consequence, WARN_ON_ONCE() will be triggered from blkdev_get_by_dev() if user scan partitions with device opened exclusively. Fix this problem by removing 'FMODE_EXCL' from disk_scan_partitions(), as it used to be. Reported-by: [email protected] Link: https://syzkaller.appspot.com/bug?extid=00cd27751f78817f167b Fixes: 2736e8e ("block: use the holder as indication for exclusive opens") Signed-off-by: Yu Kuai <[email protected]> Reviewed-by: Christian Brauner <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent e89e001 commit 985958b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

block/genhd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ int disk_scan_partitions(struct gendisk *disk, blk_mode_t mode)
366366
}
367367

368368
set_bit(GD_NEED_PART_SCAN, &disk->state);
369-
bdev = blkdev_get_by_dev(disk_devt(disk), mode, NULL, NULL);
369+
bdev = blkdev_get_by_dev(disk_devt(disk), mode & ~FMODE_EXEC, NULL,
370+
NULL);
370371
if (IS_ERR(bdev))
371372
ret = PTR_ERR(bdev);
372373
else

0 commit comments

Comments
 (0)