* FAILED: patch "[PATCH] btrfs: Use real device structure to verify dev extent" failed to apply to 4.19-stable tree
@ 2019-01-14 9:55 gregkh
2019-01-14 10:11 ` Qu Wenruo
0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2019-01-14 9:55 UTC (permalink / raw)
To: wqu, dsterba, fdmanana; +Cc: stable
The patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 1b3922a8bc74231f9a767d1be6d9a061a4d4eeab Mon Sep 17 00:00:00 2001
From: Qu Wenruo <wqu@suse.com>
Date: Tue, 8 Jan 2019 14:08:18 +0800
Subject: [PATCH] btrfs: Use real device structure to verify dev extent
[BUG]
Linux v5.0-rc1 will fail fstests/btrfs/163 with the following kernel
message:
BTRFS error (device dm-6): dev extent devid 1 physical offset 13631488 len 8388608 is beyond device boundary 0
BTRFS error (device dm-6): failed to verify dev extents against chunks: -117
BTRFS error (device dm-6): open_ctree failed
[CAUSE]
Commit cf90d884b347 ("btrfs: Introduce mount time chunk <-> dev extent
mapping check") introduced strict check on dev extents.
We use btrfs_find_device() with dev uuid and fs uuid set to NULL, and
only dependent on @devid to find the real device.
For seed devices, we call clone_fs_devices() in open_seed_devices() to
allow us search seed devices directly.
However clone_fs_devices() just populates devices with devid and dev
uuid, without populating other essential members, like disk_total_bytes.
This makes any device returned by btrfs_find_device(fs_info, devid,
NULL, NULL) is just a dummy, with 0 disk_total_bytes, and any dev
extents on the seed device will not pass the device boundary check.
[FIX]
This patch will try to verify the device returned by btrfs_find_device()
and if it's a dummy then re-search in seed devices.
Fixes: cf90d884b347 ("btrfs: Introduce mount time chunk <-> dev extent mapping check")
CC: stable@vger.kernel.org # 4.19+
Reported-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 2576b1a379c9..3e4f8f88353e 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -7825,6 +7825,18 @@ static int verify_one_dev_extent(struct btrfs_fs_info *fs_info,
ret = -EUCLEAN;
goto out;
}
+
+ /* It's possible this device is a dummy for seed device */
+ if (dev->disk_total_bytes == 0) {
+ dev = find_device(fs_info->fs_devices->seed, devid, NULL);
+ if (!dev) {
+ btrfs_err(fs_info, "failed to find seed devid %llu",
+ devid);
+ ret = -EUCLEAN;
+ goto out;
+ }
+ }
+
if (physical_offset + physical_len > dev->disk_total_bytes) {
btrfs_err(fs_info,
"dev extent devid %llu physical offset %llu len %llu is beyond device boundary %llu",
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: FAILED: patch "[PATCH] btrfs: Use real device structure to verify dev extent" failed to apply to 4.19-stable tree
2019-01-14 9:55 FAILED: patch "[PATCH] btrfs: Use real device structure to verify dev extent" failed to apply to 4.19-stable tree gregkh
@ 2019-01-14 10:11 ` Qu Wenruo
2019-01-14 10:45 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Qu Wenruo @ 2019-01-14 10:11 UTC (permalink / raw)
To: gregkh, David Sterba, Filipe Manana; +Cc: stable
[-- Attachment #1.1: Type: text/plain, Size: 3206 bytes --]
On 2019/1/14 下午5:55, gregkh@linuxfoundation.org wrote:
>
> The patch below does not apply to the 4.19-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.
>
> thanks,
>
> greg k-h
My bad, the Fixes: tag is wrong.
It's should be 05a37c48604c ("btrfs: volumes: Make sure no dev extent is
beyond device boundary"), which is not included in v4.19 stable.
Sorry for the inconvenience,
Qu
> ------------------ original commit in Linus's tree ------------------
>
> From 1b3922a8bc74231f9a767d1be6d9a061a4d4eeab Mon Sep 17 00:00:00 2001
> From: Qu Wenruo <wqu@suse.com>
> Date: Tue, 8 Jan 2019 14:08:18 +0800
> Subject: [PATCH] btrfs: Use real device structure to verify dev extent
>
> [BUG]
> Linux v5.0-rc1 will fail fstests/btrfs/163 with the following kernel
> message:
>
> BTRFS error (device dm-6): dev extent devid 1 physical offset 13631488 len 8388608 is beyond device boundary 0
> BTRFS error (device dm-6): failed to verify dev extents against chunks: -117
> BTRFS error (device dm-6): open_ctree failed
>
> [CAUSE]
> Commit cf90d884b347 ("btrfs: Introduce mount time chunk <-> dev extent
> mapping check") introduced strict check on dev extents.
>
> We use btrfs_find_device() with dev uuid and fs uuid set to NULL, and
> only dependent on @devid to find the real device.
>
> For seed devices, we call clone_fs_devices() in open_seed_devices() to
> allow us search seed devices directly.
>
> However clone_fs_devices() just populates devices with devid and dev
> uuid, without populating other essential members, like disk_total_bytes.
>
> This makes any device returned by btrfs_find_device(fs_info, devid,
> NULL, NULL) is just a dummy, with 0 disk_total_bytes, and any dev
> extents on the seed device will not pass the device boundary check.
>
> [FIX]
> This patch will try to verify the device returned by btrfs_find_device()
> and if it's a dummy then re-search in seed devices.
>
> Fixes: cf90d884b347 ("btrfs: Introduce mount time chunk <-> dev extent mapping check")
> CC: stable@vger.kernel.org # 4.19+
> Reported-by: Filipe Manana <fdmanana@suse.com>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> Signed-off-by: David Sterba <dsterba@suse.com>
>
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 2576b1a379c9..3e4f8f88353e 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -7825,6 +7825,18 @@ static int verify_one_dev_extent(struct btrfs_fs_info *fs_info,
> ret = -EUCLEAN;
> goto out;
> }
> +
> + /* It's possible this device is a dummy for seed device */
> + if (dev->disk_total_bytes == 0) {
> + dev = find_device(fs_info->fs_devices->seed, devid, NULL);
> + if (!dev) {
> + btrfs_err(fs_info, "failed to find seed devid %llu",
> + devid);
> + ret = -EUCLEAN;
> + goto out;
> + }
> + }
> +
> if (physical_offset + physical_len > dev->disk_total_bytes) {
> btrfs_err(fs_info,
> "dev extent devid %llu physical offset %llu len %llu is beyond device boundary %llu",
>
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: FAILED: patch "[PATCH] btrfs: Use real device structure to verify dev extent" failed to apply to 4.19-stable tree
2019-01-14 10:11 ` Qu Wenruo
@ 2019-01-14 10:45 ` Greg KH
0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2019-01-14 10:45 UTC (permalink / raw)
To: Qu Wenruo; +Cc: David Sterba, Filipe Manana, stable
On Mon, Jan 14, 2019 at 06:11:40PM +0800, Qu Wenruo wrote:
>
>
> On 2019/1/14 下午5:55, gregkh@linuxfoundation.org wrote:
> >
> > The patch below does not apply to the 4.19-stable tree.
> > If someone wants it applied there, or to any other stable or longterm
> > tree, then please email the backport, including the original git commit
> > id to <stable@vger.kernel.org>.
> >
> > thanks,
> >
> > greg k-h
>
> My bad, the Fixes: tag is wrong.
>
> It's should be 05a37c48604c ("btrfs: volumes: Make sure no dev extent is
> beyond device boundary"), which is not included in v4.19 stable.
Thanks for letting us know.
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-01-14 10:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-14 9:55 FAILED: patch "[PATCH] btrfs: Use real device structure to verify dev extent" failed to apply to 4.19-stable tree gregkh
2019-01-14 10:11 ` Qu Wenruo
2019-01-14 10:45 ` Greg KH
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.