From patchwork Wed Jul 7 04:40:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Ruffell X-Patchwork-Id: 1501574 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GKRjr1rzyz9srX; Wed, 7 Jul 2021 14:47:28 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1m0zT1-0005Z2-Fs; Wed, 07 Jul 2021 04:47:23 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1m0zT0-0005Yw-1t for kernel-team@lists.ubuntu.com; Wed, 07 Jul 2021 04:47:22 +0000 Received: from mail-qv1-f71.google.com ([209.85.219.71]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1m0zSz-0000Nd-Jz for kernel-team@lists.ubuntu.com; Wed, 07 Jul 2021 04:47:21 +0000 Received: by mail-qv1-f71.google.com with SMTP id k12-20020a0cfd6c0000b029020df9543019so710053qvs.14 for ; Tue, 06 Jul 2021 21:47:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NqYICp+ANAWM2gCs4HjhjgTPmQRYXgkbtOBK+LJPX9s=; b=mu4va9vwgHTdY9kn4NagaHZGHygwAG7ucjwYgFVkGSOvY+mxkwZY6KbfCJSb/d/P3i PWXB8rmFKr4FOcn6LI2hYOi4gU2g1VWGmzcOUBNEJAwP4wudua9Y6xlC5BsE/Xh/RVlz B0orYDtdfPgBGAEzkUn4jR9HzCehU3a87vsPmklV9KeXA+P00x+nerKKW5jND7n5xKM3 W0QMoL35RahMDSHkQSrn6B6P86ZQtYpFp+xixgxPgp9fJr9X3/BkWaoxLvrvTWS3MPyd SwtDEILcGFs5P3UbnxF62hz6VWW9/ZQhcRWlF9P9SnvUGv9Xd+qUR4DkMzApMfAT+G/7 LGug== X-Gm-Message-State: AOAM531KoDJrzaAZ/pVpCHic9TmYXXUKa6aES4HcCuTH+grIiHv/kSwT XYC7qY3cKpjJ837xRyhkn0In3v5ikyWChJ8cEukAIGxrKclpFanGOqBWaL1xFnbxxCJ4X9oZIDK mIrLfuhII+ynkIt+LjzxJuzjyLnS454GXI3hkyh8a7Q== X-Received: by 2002:a17:902:728e:b029:101:c3b7:a47f with SMTP id d14-20020a170902728eb0290101c3b7a47fmr19740429pll.21.1625632854686; Tue, 06 Jul 2021 21:40:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+CixMnYvimsmHonHRgYz3+xDbFjGCL2eFhQd1Yquh/CvRJhq5fqVgLYP4xJAyn5xrF1jhKw== X-Received: by 2002:a17:902:728e:b029:101:c3b7:a47f with SMTP id d14-20020a170902728eb0290101c3b7a47fmr19740416pll.21.1625632854446; Tue, 06 Jul 2021 21:40:54 -0700 (PDT) Received: from desktop.. (125-237-197-94-fibre.sparkbb.co.nz. [125.237.197.94]) by smtp.gmail.com with ESMTPSA id d1sm16861332pfu.6.2021.07.06.21.40.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jul 2021 21:40:54 -0700 (PDT) From: Matthew Ruffell To: kernel-team@lists.ubuntu.com Subject: [SRU][B][PATCH 5/6] btrfs: Fix wrong first_key parameter in replace_path Date: Wed, 7 Jul 2021 16:40:36 +1200 Message-Id: <20210707044037.37992-6-matthew.ruffell@canonical.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210707044037.37992-1-matthew.ruffell@canonical.com> References: <20210707044037.37992-1-matthew.ruffell@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Qu Wenruo BugLink: https://bugs.launchpad.net/bugs/1934709 Commit 581c1760415c ("btrfs: Validate child tree block's level and first key") introduced new @first_key parameter for read_tree_block(), however caller in replace_path() is parasing wrong key to read_tree_block(). It should use parameter @first_key other than @key. Normally it won't expose problem as @key is normally initialzied to the same value of @first_key we expect. However in relocation recovery case, @key can be set to (0, 0, 0), and since no valid key in relocation tree can be (0, 0, 0), it will cause read_tree_block() to return -EUCLEAN and interrupt relocation recovery. Fix it by setting @first_key correctly. Fixes: 581c1760415c ("btrfs: Validate child tree block's level and first key") Signed-off-by: Qu Wenruo Signed-off-by: David Sterba (cherry picked from commit 17515f1b764df36271f3166c714f5a78301fbaa7) Signed-off-by: Matthew Ruffell --- fs/btrfs/relocation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index aaa33186648b..ff953b345cb0 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -1855,7 +1855,7 @@ int replace_path(struct btrfs_trans_handle *trans, old_bytenr = btrfs_node_blockptr(parent, slot); blocksize = fs_info->nodesize; old_ptr_gen = btrfs_node_ptr_generation(parent, slot); - btrfs_node_key_to_cpu(parent, &key, slot); + btrfs_node_key_to_cpu(parent, &first_key, slot); if (level <= max_level) { eb = path->nodes[level];