]> git.baikalelectronics.ru Git - kernel.git/commit
block: Initialize bd_bdi on inode initialization
authorJan Kara <jack@suse.cz>
Thu, 2 Mar 2017 15:50:13 +0000 (16:50 +0100)
committerJens Axboe <axboe@fb.com>
Thu, 2 Mar 2017 15:56:59 +0000 (08:56 -0700)
commit7c2d7ba15edf0fd17095bcb6d05b47e48bb442a9
treedc1803bee107865dbea5c4434bad158a15a66ced
parentbd8f02480c2d95c5e4b8ab7c7293ba3110d5cf5e
block: Initialize bd_bdi on inode initialization

So far we initialized bd_bdi only in bdget(). That is fine for normal
bdev inodes however for the special case of the root inode of
blockdev_superblock that function is never called and thus bd_bdi is
left uninitialized. As a result bdev_evict_inode() may oops doing
bdi_put(root->bd_bdi) on that inode as can be seen when doing:

mount -t bdev none /mnt

Fix the problem by initializing bd_bdi when first allocating the inode
and then reinitializing bd_bdi in bdev_evict_inode().

Thanks to syzkaller team for finding the problem.

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Fixes: a96cb1ff8362 ("block: Make blk_get_backing_dev_info() safe without open bdev")
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@fb.com>
fs/block_dev.c