From patchwork Thu Jul 5 07:45:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10508325 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 41FED600F5 for ; Thu, 5 Jul 2018 07:46:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35BD828E81 for ; Thu, 5 Jul 2018 07:46:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A3A728E84; Thu, 5 Jul 2018 07:46:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C23E328E81 for ; Thu, 5 Jul 2018 07:46:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753264AbeGEHqC (ORCPT ); Thu, 5 Jul 2018 03:46:02 -0400 Received: from mx2.suse.de ([195.135.220.15]:54436 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753220AbeGEHqB (ORCPT ); Thu, 5 Jul 2018 03:46:01 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 44DC8AF54 for ; Thu, 5 Jul 2018 07:46:00 +0000 (UTC) From: Qu Wenruo To: linux-btrfs@vger.kernel.org Subject: [PATCH 1/3] btrfs: fsck/original: Don't panic out when unexpected root item is referring to one extent Date: Thu, 5 Jul 2018 15:45:56 +0800 Message-Id: <20180705074558.20022-1-wqu@suse.com> X-Mailer: git-send-email 2.18.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With crafted image, expected root item can refer to certain extent, and original mode uses BUG_ON() to handle such case. Fix it by gracefully return error. Link: https://bugzilla.kernel.org/show_bug.cgi?id=200403 Signed-off-by: Qu Wenruo --- check/main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/check/main.c b/check/main.c index 8db300abb825..6f1182106071 100644 --- a/check/main.c +++ b/check/main.c @@ -3724,7 +3724,12 @@ static int check_owner_ref(struct btrfs_root *root, if (btrfs_header_owner(buf) == back->root) return 0; } - BUG_ON(rec->is_root); + /* + * Some unexpected root item referring to this one, return 1 to + * indicate owner not found + */ + if (rec->is_root) + return 1; /* try to find the block by search corresponding fs tree */ key.objectid = btrfs_header_owner(buf);