diff options
| author | Filipe Manana <fdmanana@suse.com> | 2026-10-16 17:53:00 +0100 |
|---|---|---|
| committer | David Sterba <dsterba@suse.com> | 2026-10-30 23:15:07 +0100 |
| commit | e6dc2b2e22556d88bf4ce9e7821ddd40c061f635 (patch) | |
| tree | 1b1ac40f2417a9d1102161093cec3e3d73947a79 /scripts/dummy-tools/python3 | |
| parent | bda65e5115fe66ee0d8cf4ade11807f9fca4f0e1 (diff) | |
btrfs: scrub: fix race leading to use-after-free in the scrub progress ioctl
If the scrub progress ioctl is called when replace is about to finish, we
have a race that can result in a use-after-free of the scrub context:
1) A scrub is finishing and is at btrfs_scrub_dev();
2) A concurrent task called the scrub progress ioctl and is in
btrfs_scrub_progress(), where it takes the device_list_mutex and grabs
the device. Then it starts using the device's scrub context (for a
memcpy operation);
3) While the scrub progress ioctl task is running, the scrub task sets
the device's scrub_ctx to NULL (acquiring fs_info->scrub_lock) and
then calls scrub_put_ctx() against the scrub context, dropping the
last reference and freeing the memory - while the scrub progress ioctl
task is still using it, resulting in a use-after-free.
Fix this by changing btrfs_scrub_progress() to take fs_info->scrub_lock
before using the scrub context.
Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Daniel Vacek <neelx@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'scripts/dummy-tools/python3')
0 files changed, 0 insertions, 0 deletions
