From patchwork Fri Nov 24 10:41:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gu Jinxiang X-Patchwork-Id: 10073937 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 3A98F6037F for ; Fri, 24 Nov 2017 10:41:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 356D42A27C for ; Fri, 24 Nov 2017 10:41:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A69B2A283; Fri, 24 Nov 2017 10:41:41 +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=-6.9 required=2.0 tests=BAYES_00,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 9E3142A27C for ; Fri, 24 Nov 2017 10:41:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753254AbdKXKlh (ORCPT ); Fri, 24 Nov 2017 05:41:37 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:32752 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753100AbdKXKlg (ORCPT ); Fri, 24 Nov 2017 05:41:36 -0500 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="30431329" Received: from localhost (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 24 Nov 2017 18:41:35 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id 89986487F16D; Fri, 24 Nov 2017 18:41:33 +0800 (CST) Received: from localhost.localdomain (10.167.226.132) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 24 Nov 2017 18:41:33 +0800 From: Gu Jinxiang To: CC: Subject: [PATCH 1/5] btrfs-progs: Add location check when process share_data_ref item Date: Fri, 24 Nov 2017 18:41:28 +0800 Message-ID: <1511520092-37101-1-git-send-email-gujx@cn.fujitsu.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.167.226.132] X-yoursite-MailScanner-ID: 89986487F16D.A5C97 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: gujx@cn.fujitsu.com 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 The following test failed becasuse share_data_ref be added into extent_cache when deal with root tree node. $sudo TEST=003\* make test-fuzz cmds-check.c:5660: check_owner_ref: BUG_ON `rec->is_root` triggered, value 1 /home/adam/btrfs/btrfs-progs/btrfs[0x46a43b] /home/adam/btrfs/btrfs-progs/btrfs[0x46a529] /home/adam/btrfs/btrfs-progs/btrfs[0x479e55] /home/adam/btrfs/btrfs-progs/btrfs[0x47af81] /home/adam/btrfs/btrfs-progs/btrfs[0x47f69e] /home/adam/btrfs/btrfs-progs/btrfs[0x484680] /home/adam/btrfs/btrfs-progs/btrfs[0x484cb9] /home/adam/btrfs/btrfs-progs/btrfs[0x4884f9] /home/adam/btrfs/btrfs-progs/btrfs(cmd_check+0xb53)[0x48b7c3] /home/adam/btrfs/btrfs-progs/btrfs(main+0x127)[0x40b39d] /lib64/libc.so.6(__libc_start_main+0xea)[0x7f9ac76db03a] /home/adam/btrfs/btrfs-progs/btrfs(_start+0x2a)[0x40ac9a] failed (ignored, ret=134): /home/adam/btrfs/btrfs-progs/btrfs check --check-data-csum /home/adam/btrfs/btrfs-progs/tests/fuzz-tests/images/bko-156731.raw.restored mayfail: returned code 134 (SIGABRT), not ignored test failed for case 003-multi-check-unmounted Signed-off-by: Gu Jinxiang --- cmds-check.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmds-check.c b/cmds-check.c index 5c822b84..71b15de4 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -8018,6 +8018,14 @@ static int run_next_block(struct btrfs_root *root, } if (key.type == BTRFS_SHARED_DATA_REF_KEY) { struct btrfs_shared_data_ref *ref; + if (root->root_key.objectid != + BTRFS_EXTENT_TREE_OBJECTID) { + error( + "invaild location of share_data_ref [%d %d] root %d", + key.objectid, key.offset, + root->root_key.objectid); + continue; + } ref = btrfs_item_ptr(buf, i, struct btrfs_shared_data_ref); add_data_backref(extent_cache,