From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH v2 0/2] btrfs: scrub: fix several races which can lead to UAF
Date: Wed, 18 Nov 2026 08:18:28 +1030 [thread overview]
Message-ID: <cover.1794951798.git.wqu@suse.com> (raw)
[CHANGELOG]
v2:
- Fix the race charts where the sequence is incorrect
All functions are shown when there is enough space.
Also re-order the functions to properly represent their correct time
sequence.
- Do not use non-upstream commit number in the commit message
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
next reply other threads:[~2026-11-17 21:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 21:48 Qu Wenruo [this message]
2026-11-17 21:48 ` [PATCH v2 1/2] btrfs: scrub: fix use-after-free when waking up the repair waiter Qu Wenruo
2026-11-17 21:48 ` [PATCH v2 2/2] btrfs: scrub: fix use-after-free when waking up the stripe I/O waiter Qu Wenruo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1794951798.git.wqu@suse.com \
--to=wqu@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.