Skip to content

Fix locking when scanning devices

David Sterba linux-btrfs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest7 patches 13 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7btrfs: restore uuid_mutex in btrfs_open_devicesfs/btrfs/volumes.c+2 -02 replies
2/7btrfs: extend critical section when scanning a new devicefs/btrfs/volumes.c+2 -33 replies
3/7btrfs: lift uuid_mutex to callers of btrfs_scan_one_devicefs/btrfs/super.c fs/btrfs/volumes.c+13 -31 reply
4/7btrfs: lift uuid_mutex to callers of btrfs_open_devicesfs/btrfs/super.c fs/btrfs/volumes.c+4 -21 reply
5/7btrfs: lift uuid_mutex to callers of btrfs_parse_early_optionsfs/btrfs/super.c+4 -21 reply
6/7btrfs: reorder initialization before the mount locks uuid_mutexfs/btrfs/super.c+14 -161 reply
7/7btrfs: fix mount and ioctl device scan ioctl racefs/btrfs/super.c+6 -62 replies

Reviews trailers per patch

6 of 7 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

Patch[email protected][email protected]Nikolay BorisovAnand Jain
SeriesR-b
1/7R-b
2/7
3/7R-b
4/7R-b
5/7R-b
6/7R-b
7/7Reported-and-tested-by Reported-and-tested-by R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v1 thread

Cover letter [PATCH 0/7] Fix locking when scanning devices

This patchset fixes the bugs recently reported by syzbot. I've tried to use patches from Anand [1] to fix that but in the end there were fixes not suitable for merging to 4.18 and my final fix took a different approach.

In short, fs_devices::opened is protected by uuid_mutex and this mutex can be used to exclude mount and scanning to interfere.

The fstests pass and 2 syzbot reproducers reported no problems. I'd like to push the patchset to 4.18 but not rc2 as it's too close. I'll add the patchset to for-next soon if there are no major problems found, but otherwise I'm open to comments.

[1]
https://patchwork.kernel.org/patch/10446779/
https://patchwork.kernel.org/patch/10437707/ 1-6

David Sterba (7):
btrfs: restore uuid_mutex in btrfs_open_devices
btrfs: extend critical section when scanning a new device
btrfs: lift uuid_mutex to callers of btrfs_scan_one_device
btrfs: lift uuid_mutex to callers of btrfs_open_devices
btrfs: lift uuid_mutex to callers of btrfs_parse_early_options
btrfs: reorder initialization before the mount locks uuid_mutex
btrfs: fix mount and ioctl device scan ioctl race

 fs/btrfs/super.c   | 38 +++++++++++++++++++++++++-------------
 fs/btrfs/volumes.c | 11 ++++++-----
 2 files changed, 31 insertions(+), 18 deletions(-)
Signature · 1 line
2.17.0