Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH 0/2] btrfs: scrub: fix several races which can lead to UAF
@ 2026-11-16 22:34 Qu Wenruo
  2026-11-16 22:34 ` [PATCH 1/2] btrfs: scrub: fix use-after-free when waking up the repair waiter Qu Wenruo
  2026-11-16 22:34 ` [PATCH 2/2] btrfs: scrub: fix use-after-free when waking up the stripe I/O waiter Qu Wenruo
  0 siblings, 2 replies; 3+ messages in thread
From: Qu Wenruo @ 2026-11-16 22:34 UTC (permalink / raw)
  To: linux-btrfs

This is inspired by the fix in raid56:
https://lore.kernel.org/linux-btrfs/20261116001903.63524-1-mc@raidlab.org/

And there are two similar cases inside scrub.c:
- scrub_stripe::repair_wait
- scrub_stripe::io_wait

The only difference is, the window is much smaller compared to RAID56,
as most scrub_stripe structure have a very long lifespan, as long as the
scrub/replace ioctl. Only the RAID56 data stripes has a shorter
lifespan.

But still it's possible in theory, so here comes the same fix for scrub.

For repair_wait it's pretty straight foward.

For io_wait we have several locations that we submit a batch of bios in
one go, and pending_io may drop to zero during IOs.
Follow the existing behavior by grabbing one extra ref to ensure the
pending_io won't reach zero during IOs.

Qu Wenruo (2):
  btrfs: scrub: fix use-after-free when waking up the repair waiter
  btrfs: scrub: fix use-after-free when waking up the stripe I/O waiter

 fs/btrfs/scrub.c | 116 +++++++++++++++++++++++++++++++----------------
 1 file changed, 77 insertions(+), 39 deletions(-)

-- 
2.56.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-16 22:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16 22:34 [PATCH 0/2] btrfs: scrub: fix several races which can lead to UAF Qu Wenruo
2026-11-16 22:34 ` [PATCH 1/2] btrfs: scrub: fix use-after-free when waking up the repair waiter Qu Wenruo
2026-11-16 22:34 ` [PATCH 2/2] btrfs: scrub: fix use-after-free when waking up the stripe I/O waiter Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox