Skip to content

btrfs: fixes for relocation to avoid KASAN reports

Qu Wenruo linux-btrfs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 14 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3btrfs: relocation: Fix a KASAN use-after-free bug due to extended reloc tree lifespanfs/btrfs/relocation.c+4 -01 reply
2/3btrfs: relocation: Fix KASAN report on create_reloc_tree due to extended reloc tree lifepsanfs/btrfs/relocation.c+8 -12 replies
3/3btrfs: relocation: Fix a KASAN report on btrfs_reloc_pre_snapshot() due to extended reloc root lifespanfs/btrfs/relocation.c+2 -11 reply

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchJosef Bacik
1/3R-b
2/3R-b
3/3R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/3] btrfs: fixes for relocation to avoid KASAN reports

Due to commit d2311e698578 ("btrfs: relocation: Delay reloc tree deletion after merge_reloc_roots"), reloc tree lifespan is extended.

Although we always set root->reloc_root to NULL before we drop the reloc tree, but that's not multi-core safe since we have no proper memory barrier to ensure other cores can see the same root->reloc_root.

The proper root fix should be some proper root refcount, and make btrfs_drop_snapshot() to wait for all other root owner to release the root before dropping it.

But for now, let's just check the DEAD_RELOC_ROOT bit before accessing root->reloc_root.

Qu Wenruo (3):
btrfs: relocation: Fix a KASAN use-after-free bug due to extended
reloc tree lifespan
btrfs: relocation: Fix KASAN report on create_reloc_tree due to
extended reloc tree lifepsan
btrfs: relocation: Fix a KASAN report on btrfs_reloc_pre_snapshot()
due to extended reloc root lifespan

 fs/btrfs/relocation.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
Signature · 1 line
2.24.0