Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3645060pxb; Mon, 24 Jan 2022 14:17:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJz5DIdUDK9rGfygnUM6hmlHKUs8+ZOGGvXy9kBZlgBw3oJlFF6s+eUEYfUtygBVXOr1WOK2 X-Received: by 2002:a17:90a:fe1:: with SMTP id 88mr394622pjz.150.1643062647059; Mon, 24 Jan 2022 14:17:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643062647; cv=none; d=google.com; s=arc-20160816; b=l5NLVm8S+i8GQE6Z884plXhrzrdi2/pWJDDGQc7CJXRTtp+ez6T7sCirZuo98tF7Sz Z9rp9uB9+k8LPVTdIG4VO7MkrJEdmTQJJsh3FLRaSwgDCkSpnpoU6ZX6cu0qiCQdmckq lbLDIyP1taXbCimOsRcCdOI/Bu1RqYfo6BEUjQFBuYvyN52mulThyxmTzDhS9dEs7La9 r3qmTlz3eaTDVKKX0IJl1g+j9kS7ac6q8ffDMoc/pFq1RT3mVqjJeSadqyxj2R+jzGfj EsXg/b34BWImJor0D9oU9n2DVjn4S9bn8fjV7kdIELLO4XAL/Wi78eLR3PJt1SU2vZk/ S1uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/CzdPJhk1Vch7O9pE30+V7dMHvvyAGVi98uNhJBl41E=; b=Gk92iMEeEE0kVxVpTMpw4ZZF3KUW6Q5VEKGsqBW2EtbgCv7OnaL9fDcNOWBHZ68ZRJ AO1R8NQNsj+RZeLSbIEig4jbmSNS4TH/0BVnlHzLJzAzJAMtsNUhUzXlF+xw6rxcpIGv O2y3sWjT/NYJtL1/Iol15alnok2zmuGcXT2VaH1HGh+yc5bUNYfOpY8uceWe/efp1ued c2dp6S0H+KD8Nm2XhzuYqkhdJMvLbDqRS9TlHQPVTWu/BLhVjHVCOD+zOvKvNmFknVMU MlUvNa7IwsPJgNmYx9RsXFUXVEtDH2BsETAsgVVjvfBTCCU07FQhadWSfGSpvDdu/tS+ ecpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hFinnNtj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v2si487730pjk.76.2022.01.24.14.17.11; Mon, 24 Jan 2022 14:17:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hFinnNtj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1581872AbiAXWMd (ORCPT + 99 others); Mon, 24 Jan 2022 17:12:33 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:49188 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351709AbiAXV2k (ORCPT ); Mon, 24 Jan 2022 16:28:40 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0AC116151E; Mon, 24 Jan 2022 21:28:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E418DC33E64; Mon, 24 Jan 2022 21:28:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643059719; bh=eZwEiXJyPGEonfCjOOp7aKHAaSn0sBKdsFPzaIWm9G4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hFinnNtjW1COtpuV08egxGh/CBiVPMcnYEt4DFSrqV9VXYgNG0GbmSQo0iw8XnHR5 brB3waaFaZD99eByS6s9IZ7MHKVyVDI7MCTBeNxVd1ioJNWlBw0Lk/YK9g9B82vGO6 Owvfw2t8hnEeNWi2ggE5uSGCXbKIPkKCxAiPUYMM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Josef Bacik , David Sterba , Sasha Levin Subject: [PATCH 5.16 0710/1039] btrfs: remove BUG_ON(!eie) in find_parent_nodes Date: Mon, 24 Jan 2022 19:41:39 +0100 Message-Id: <20220124184149.204909875@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Josef Bacik [ Upstream commit 9f05c09d6baef789726346397438cca4ec43c3ee ] If we're looking for leafs that point to a data extent we want to record the extent items that point at our bytenr. At this point we have the reference and we know for a fact that this leaf should have a reference to our bytenr. However if there's some sort of corruption we may not find any references to our leaf, and thus could end up with eie == NULL. Replace this BUG_ON() with an ASSERT() and then return -EUCLEAN for the mortals. Signed-off-by: Josef Bacik Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- fs/btrfs/backref.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index 6b4b0f105a572..8b090c40daf77 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c @@ -1365,10 +1365,18 @@ again: goto out; if (!ret && extent_item_pos) { /* - * we've recorded that parent, so we must extend - * its inode list here + * We've recorded that parent, so we must extend + * its inode list here. + * + * However if there was corruption we may not + * have found an eie, return an error in this + * case. */ - BUG_ON(!eie); + ASSERT(eie); + if (!eie) { + ret = -EUCLEAN; + goto out; + } while (eie->next) eie = eie->next; eie->next = ref->inode_list; -- 2.34.1