All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Anand Jain <anand.jain@oracle.com>
Cc: Christoph Hellwig <hch@infradead.org>,
	boris@bur.io, dsterba@suse.com, linux-btrfs@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH v2] btrfs: validate device maj:min during open
Date: Fri, 8 Mar 2024 09:23:52 -0800	[thread overview]
Message-ID: <ZetJqJH-K-fC-pC-@infradead.org> (raw)
In-Reply-To: <9a59cfac-2ab4-4c6c-933a-70dcd3e3d80b@oracle.com>

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@bur.io/
> 
> 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


  reply	other threads:[~2024-03-08 17:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-08  2:45 [PATCH v2] btrfs: validate device maj:min during open Anand Jain
2024-03-08 15:48 ` Christoph Hellwig
2024-03-08 16:04   ` Anand Jain
2024-03-08 16:10     ` Christoph Hellwig
2024-03-08 16:23       ` Anand Jain
2024-03-08 17:23         ` Christoph Hellwig [this message]
2024-03-08 17:32           ` Boris Burkov
2024-03-08 17:42             ` Christoph Hellwig
2024-03-08 17:51               ` Boris Burkov
2024-03-13 16:24                 ` Anand Jain
2024-03-08 17:41 ` Boris Burkov
2024-03-12 19:17   ` Boris Burkov
2024-03-13 10:25     ` Anand Jain

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=ZetJqJH-K-fC-pC-@infradead.org \
    --to=hch@infradead.org \
    --cc=anand.jain@oracle.com \
    --cc=boris@bur.io \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=stable@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.