From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 373FFC43444 for ; Mon, 14 Jan 2019 09:55:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0611820656 for ; Mon, 14 Jan 2019 09:55:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547459711; bh=m+rw1C6Wx7Y65iihXZOl2eMOhrajpO9o89yTZDOr7HE=; h=Subject:To:Cc:From:Date:List-ID:From; b=F8pDw8yUwj9D4I2duMhFTXJPHsTz619C4ZBKd5ove5yZyDIe5qyMOiBDXqmODcDih ShssYN/VjuN8UQc3RQcrCsaXxoNC8xWgHqoEc6+PtMUn+4MLZU4Lfr9YQFzPTRXsDS BO9/84epN4WuVE2Rzd+NBZH6dV1iBH3ieLSjASFo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726306AbfANJzK (ORCPT ); Mon, 14 Jan 2019 04:55:10 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:39059 "EHLO wout2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726546AbfANJzF (ORCPT ); Mon, 14 Jan 2019 04:55:05 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id A284B1834; Mon, 14 Jan 2019 04:55:04 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 14 Jan 2019 04:55:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=YDeqs/ X/i4ODUbYGfAcpWLHj9iI/zucZpJ2EbKbOk44=; b=MF+W2YqFojrqYgSGeYSrUK FZluyULdeiH76WwvaJeZhNdYDceMK2LsH2J5Qp+mjrNlm7QKsHSckLCzk3jD3+df 5n1XMayb2XgIKl6Cmk37IIkKaY6dnxx3y8eOqohhtccZKhSMf5cIA3Ea5tBvl61G Npja31HDcJibfVd7/uWB3vGVirscc1REBM4MW5+83zCjvgaiyg5Pg9Ai0KWgRRTP bDEjvC1w9v/RboFhch6HiwPKhP9rPd1GlIAOZPZXyONBMSRPiDG7nPMRZ538is0/ o/JTOlAqstyRd5oyI66Xg+9k+4MlKyp6WnoAwGGXX5q+bkkps++Dkrhg216KUS2w == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledrgedugddutdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecufedt tdenucenucfjughrpefuvffhfffkgggtgfesthekredttddtlfenucfhrhhomhepoehgrh gvghhkhheslhhinhhugihfohhunhgurghtihhonhdrohhrgheqnecukfhppedvuddvrddu jeekrddvudeirddukeenucfrrghrrghmpehmrghilhhfrhhomhepghhrvghgsehkrhhorg hhrdgtohhmnecuvehluhhsthgvrhfuihiivgepud X-ME-Proxy: Received: from localhost (d4b2d812.static.ziggozakelijk.nl [212.178.216.18]) by mail.messagingengine.com (Postfix) with ESMTPA id 9A558E459A; Mon, 14 Jan 2019 04:55:03 -0500 (EST) Subject: FAILED: patch "[PATCH] btrfs: Use real device structure to verify dev extent" failed to apply to 4.19-stable tree To: wqu@suse.com, dsterba@suse.com, fdmanana@suse.com Cc: From: Date: Mon, 14 Jan 2019 10:55:01 +0100 Message-ID: <15474597012750@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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 . thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 1b3922a8bc74231f9a767d1be6d9a061a4d4eeab Mon Sep 17 00:00:00 2001 From: Qu Wenruo 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 Signed-off-by: Qu Wenruo Signed-off-by: David Sterba 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",