]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
btrfs: subpage: fix the bitmap dump which can cause bitmap corruption
authorQu Wenruo <wqu@suse.com>
Fri, 30 Aug 2024 07:05:48 +0000 (16:35 +0930)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 4 Oct 2024 14:33:36 +0000 (16:33 +0200)
commit1d3589834b00c2b421940dfba16cbf57d4aca29a
treeff77ce3ae59217eb33b53605da82ddf46e0e3ba2
parent16d277b3e920ee4cfe06316a7c7b14394b3f2e24
btrfs: subpage: fix the bitmap dump which can cause bitmap corruption

commit 77b0b98bb743f5d04d8f995ba1936e1143689d4a upstream.

In commit 75258f20fb70 ("btrfs: subpage: dump extra subpage bitmaps for
debug") an internal macro GET_SUBPAGE_BITMAP() is introduced to grab the
bitmap of each attribute.

But that commit is using bitmap_cut() which will do the left shift of
the larger bitmap, causing incorrect values.

Thankfully this bitmap_cut() is only called for debug usage, and so far
it's not yet causing problem.

Fix it to use bitmap_read() to only grab the desired sub-bitmap.

Fixes: 75258f20fb70 ("btrfs: subpage: dump extra subpage bitmaps for debug")
CC: stable@vger.kernel.org # 6.6+
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/subpage.c