]> www.infradead.org Git - users/willy/pagecache.git/commit
btrfs: fix use-after-free on inode when scanning root during em shrinking
authorFilipe Manana <fdmanana@suse.com>
Sat, 15 Feb 2025 11:36:15 +0000 (11:36 +0000)
committerDavid Sterba <dsterba@suse.com>
Fri, 21 Feb 2025 08:31:48 +0000 (09:31 +0100)
commit59f37036bb7ab3d554c24abc856aabca01126414
tree5524649f231619054440a3e27d9c5f555c03e06c
parent290237fde9491ca26cf4020bbf5a2b330452e7db
btrfs: fix use-after-free on inode when scanning root during em shrinking

At btrfs_scan_root() we are accessing the inode's root (and fs_info) in a
call to btrfs_fs_closing() after we have scheduled the inode for a delayed
iput, and that can result in a use-after-free on the inode in case the
cleaner kthread does the iput before we dereference the inode in the call
to btrfs_fs_closing().

Fix this by using the fs_info stored already in a local variable instead
of doing inode->root->fs_info.

Fixes: 102044384056 ("btrfs: make the extent map shrinker run asynchronously as a work queue job")
CC: stable@vger.kernel.org # 6.13+
Tested-by: Ivan Shapovalov <intelfx@intelfx.name>
Link: https://lore.kernel.org/linux-btrfs/0414d690ac5680d0d77dfc930606cdc36e42e12f.camel@intelfx.name/
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent_map.c