]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: Prevent scrub recheck from racing with dev replace
authorQu Wenruo <quwenruo@cn.fujitsu.com>
Wed, 29 Mar 2017 01:33:22 +0000 (09:33 +0800)
committerDavid Sterba <dsterba@suse.com>
Tue, 18 Apr 2017 12:07:26 +0000 (14:07 +0200)
commit5644e3b6d0aa99ba0a83e1fdb735f7b49962911d
tree870724f193b99f9388dce8e7cbdfcb96b3cfeed5
parent2d3b53950924c65478cf27843bf93d66bb444793
btrfs: Prevent scrub recheck from racing with dev replace

scrub_setup_recheck_block() calls btrfs_map_sblock() and then accesses
bbio without protection of bio_counter.

This can lead to use-after-free if racing with dev replace cancel.

Fix it by increasing bio_counter before calling btrfs_map_sblock() and
decreasing the bio_counter when corresponding recover is finished.

Cc: Liu Bo <bo.li.liu@oracle.com>
Reported-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/scrub.c