]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: avoid double put of block group when emptying cluster
authorJosef Bacik <josef@toxicpanda.com>
Mon, 25 Jan 2021 21:42:35 +0000 (16:42 -0500)
committerDavid Sterba <dsterba@suse.com>
Mon, 22 Feb 2021 17:07:45 +0000 (18:07 +0100)
commit01da367627e3394e8aca6b4dc8e0eb02bcbc8de2
tree94759fd6b4bb04faa4daabca4a1c75583be1757d
parent4a4786de5acdff91257cc4f42293b003d354b98d
btrfs: avoid double put of block group when emptying cluster

It's wrong calling btrfs_put_block_group in
__btrfs_return_cluster_to_free_space if the block group passed is
different than the block group the cluster represents. As this means the
cluster doesn't have a reference to the passed block group. This results
in double put and a use-after-free bug.

Fix this by simply bailing if the block group we passed in does not
match the block group on the cluster.

Fixes: 01f76b315e70 ("Btrfs: rework allocation clustering")
CC: stable@vger.kernel.org # 4.4+
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
[ update changelog ]
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/free-space-cache.c