]> www.infradead.org Git - users/hch/xfstests-dev.git/commit
fstests: btrfs: test reading data with a corrupted checksum tree leaf
authorQu Wenruo <wqu@suse.com>
Tue, 27 Aug 2024 00:13:54 +0000 (09:43 +0930)
committerZorro Lang <zlang@kernel.org>
Mon, 2 Sep 2024 20:32:31 +0000 (04:32 +0800)
commit66a2179efbde1fc2639419edac23494a8e8f75e9
treed8afe3810f0b9184c4d67c1eae13c97ab5109d2f
parent869685f2f308a3b79cd97ad90923d2b595b916d4
fstests: btrfs: test reading data with a corrupted checksum tree leaf

[BUG]
There is a bug report that, KASAN get triggered when:

- A read bio needs to be split
  This can happen for profiles with stripes, including
  RAID0/RAID10/RAID5/RAID6.

- An error happens before submitting the new split bio
  This includes:
  * chunk map lookup failure
  * data csum lookup failure

Then during the error path of btrfs_submit_chunk(), the original bio is
fully freed before submitted range has a chance to call its endio
function, resulting a use-after-free bug.

[NEW TEST CASE]
Introduce a new test case to verify the specific behavior by:

- Create a btrfs with enough csum leaves with data RAID0 profile
  To bump the csum tree level, use the minimal nodesize possible (4K).
  Writing 32M data which needs at least 8 leaves for data checksum

  RAID0 profile ensures the data read bios will get split.

- Find the last csum tree leave and corrupt it

- Read the data many times until we trigger the bug or exit gracefully
  With an x86_64 VM with KASAN enabled, it can trigger the KASAN report in
  just 4 iterations (the default iteration number is 32).

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/btrfs/321 [new file with mode: 0755]
tests/btrfs/321.out [new file with mode: 0644]