All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: 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 21:34:03 +0530	[thread overview]
Message-ID: <be3571d7-2bfe-4bad-b2c6-84a0bf121140@oracle.com> (raw)
In-Reply-To: <ZeszQwa8721XnZsY@infradead.org>



On 3/8/24 21:18, Christoph Hellwig wrote:
> On Fri, Mar 08, 2024 at 08:15:07AM +0530, Anand Jain wrote:
>> @@ -692,6 +692,16 @@ static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices,
>>   	device->bdev = bdev_handle->bdev;
>>   	clear_bit(BTRFS_DEV_STATE_IN_FS_METADATA, &device->dev_state);
>>   
>> +	if (device->devt != device->bdev->bd_dev) {
>> +		btrfs_warn(NULL,
>> +			   "device %s maj:min changed from %d:%d to %d:%d",
>> +			   device->name->str, MAJOR(device->devt),
>> +			   MINOR(device->devt), MAJOR(device->bdev->bd_dev),
>> +			   MINOR(device->bdev->bd_dev));
>> +
>> +		device->devt = device->bdev->bd_dev;
>> +	}
> 
> Just above this calls btrfs_get_bdev_and_sb, which calls
> bdev_open_by_path.  bdev_open_by_path bdev_open_by_path calls
> lookup_bdev to translate the path to a dev_t and then calls
> bdev_open_by_dev on the dev_t, which stored the passes in dev_t in
> bdev->bd_dev.  I see absolutely no way how this check could ever
> trigger.
> 

Prior to this patch, the device->devt value of the device could become
stale, as it might not have been updated since the last scan of the
device. During this interval, the device could have undergone changes
to its devt.

Thanks, Anand

  reply	other threads:[~2024-03-08 16:04 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 [this message]
2024-03-08 16:10     ` Christoph Hellwig
2024-03-08 16:23       ` Anand Jain
2024-03-08 17:23         ` Christoph Hellwig
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=be3571d7-2bfe-4bad-b2c6-84a0bf121140@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=boris@bur.io \
    --cc=dsterba@suse.com \
    --cc=hch@infradead.org \
    --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.