Skip to content

Commit dd7bc81

Browse files
dhowellstorvalds
authored andcommitted
Fix use after free in get_tree_bdev()
Commit 6fcf0c7, a fix to get_tree_bdev() put a missing blkdev_put() in the wrong place, before a warnf() that displays the bdev under consideration rather after it. This results in a silent lockup in printk("%pg") called via warnf() from get_tree_bdev() under some circumstances when there's a race with the blockdev being frozen. This can be caused by xfstests/tests/generic/085 in combination with Lukas Czerner's ext4 mount API conversion patchset. It looks like it ought to occur with other users of get_tree_bdev() such as XFS, but apparently doesn't. Fix this by switching the order of the lines. Fixes: 6fcf0c7 ("vfs: add missing blkdev_put() in get_tree_bdev()") Reported-by: Lukas Czerner <[email protected]> Signed-off-by: David Howells <[email protected]> cc: Ian Kent <[email protected]> cc: Al Viro <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent edb98d1 commit dd7bc81

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/super.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1302,8 +1302,8 @@ int get_tree_bdev(struct fs_context *fc,
13021302
mutex_lock(&bdev->bd_fsfreeze_mutex);
13031303
if (bdev->bd_fsfreeze_count > 0) {
13041304
mutex_unlock(&bdev->bd_fsfreeze_mutex);
1305-
blkdev_put(bdev, mode);
13061305
warnf(fc, "%pg: Can't mount, blockdev is frozen", bdev);
1306+
blkdev_put(bdev, mode);
13071307
return -EBUSY;
13081308
}
13091309

0 commit comments

Comments
 (0)