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 E5FE4C43444 for ; Mon, 14 Jan 2019 09:55:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B343C20821 for ; Mon, 14 Jan 2019 09:55:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547459705; bh=AIsQ1MA4Z9hnwqa7cFDhzUe60+HponesAJgqRI974c4=; h=Subject:To:Cc:From:Date:List-ID:From; b=RB6UTc1fTzJhQQCs7QHLYlZLA/S9yJoR8sfCquVSpCr3uzbLwogiW9cvq9k138Xa9 X+HyC9H5PFrLj5yjnFzGd6GnCs7CQMwscip8zbDCNbJamCFxiOFxWbqkJT/+Fb0LFl XcRcG0jmuLzaXyUIoaQP1ziwso6ROkqWlVmLyoOI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726666AbfANJzE (ORCPT ); Mon, 14 Jan 2019 04:55:04 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:47401 "EHLO wout2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726546AbfANJzA (ORCPT ); Mon, 14 Jan 2019 04:55:00 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 2F2BD171B; Mon, 14 Jan 2019 04:54:59 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 14 Jan 2019 04:54:59 -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=n8ObMC seZlw1KeXbWMea88aT3ONKAO9WRxapBm6bIXk=; b=RQjxi7E04ktJWZgV/asQe/ 57nibDxZsDUgtTfGvasu533g5k9gzAtlhCEiMVQRqUy1CotZ5HIRCfuxNf/YDYsy 3e444m7COFwjkYxgZ3NWlP5vtLqJOZRD3bg9PhU3MweDd/VUxttcj4nlUIR1UEyU 9T8oGeSzMfIlimP5Nz9zGz250ehr/KKVmg4ulCfmV2kVhzJ+lZflT3zCN3Jc617S IyrJDbasYhErfuAskAhPsIFMv+HdSq3BOezDvIp4bm6ELBo4jYSvgCXzLoxzRfnp wLZshNaEv2irSdOS76qRmcGvg/JjJZr57aAdM970GAVfpt5/wCLNSfgbzNOUrn3w == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledrgedugddutdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecufedt tdenucenucfjughrpefuvffhfffkgggtgfesthekredttddtlfenucfhrhhomhepoehgrh gvghhkhheslhhinhhugihfohhunhgurghtihhonhdrohhrgheqnecukfhppedvuddvrddu jeekrddvudeirddukeenucfrrghrrghmpehmrghilhhfrhhomhepghhrvghgsehkrhhorg hhrdgtohhmnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from localhost (d4b2d812.static.ziggozakelijk.nl [212.178.216.18]) by mail.messagingengine.com (Postfix) with ESMTPA id 19099E4598; Mon, 14 Jan 2019 04:54:57 -0500 (EST) Subject: FAILED: patch "[PATCH] btrfs: Use real device structure to verify dev extent" failed to apply to 4.20-stable tree To: wqu@suse.com, dsterba@suse.com, fdmanana@suse.com Cc: From: Date: Mon, 14 Jan 2019 10:54:56 +0100 Message-ID: <154745969645148@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.20-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",