Re: [PATCH v2] btrfs: validate device maj:min during open

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Mar 08, 2024 at 09:53:07PM +0530, Anand Jain wrote:
> It's a bit complex, as Boris discovered and has provided a testcase
> for here:
> 
> https://lore.kernel.org/fstests/f40e347d5a4b4b28201b1a088d38a3c75dd10ebd.1709251328.git.boris@xxxxxx/
> 
> In essence:
> 
>  - Create two devices, d1 and d2.
>  - Both devices will be scanned into the kernel by Mfks.
>  - Use an external method to alter the devt of the d2 device.
>  - Mount using d1.
>  - You end up with a 2 devices Btrfs with an incorrect device->devt.
>  - Delete d1.
>  - Now you have a single-device Btrfs on d2 with a stale device->devt.

But how do you get mismatching devices in this exact place?

  - bdev->bd_dev is immutable and never updated
  - device->devt can be changed by device_list_add, but if that happens
    underneath us here between btrfs_get_bdev_and_sb and the code a few
    lines below the call to it in btrfs_open_one_device there is a huge
    synchronization problem





[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux