From patchwork Mon Nov 18 05:53:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 11248895 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AAE4414ED for ; Mon, 18 Nov 2019 05:54:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8019E20727 for ; Mon, 18 Nov 2019 05:54:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ie4AieeQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726302AbfKRFxl (ORCPT ); Mon, 18 Nov 2019 00:53:41 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:39084 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726168AbfKRFxl (ORCPT ); Mon, 18 Nov 2019 00:53:41 -0500 Received: by mail-pl1-f193.google.com with SMTP id o9so9122626plk.6 for ; Sun, 17 Nov 2019 21:53:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wRy4gkCiDmjWgFgJgp6H2Spf2zxLT0v4LF/Q/YKKLTU=; b=ie4AieeQl4aCeBfs3zkYgqDWYB8USLmfr1F0YUpj3gprQ4w2K43/Xf2lQeYNAwQe3p AKGv5qjcis6UtH/Az+1mvwGtwWuSHR2jRxjDGBCEhEZPlhMXpMPREfk3TSMlNibLJc3u prtkl6mktTx1pmpWV6uWa1M7aqpZfT02vwTWq/PB/Spq1yntKS/CIUQqQvxVUu2H+wtp bP2JEtkX0pSvr4Eo0nPtlMzfFSATOSN+iWbkMrjHnz75RIKzxzuqJEUQUxJNqbmsJtRA xk+4+gElWeV/GQs959Yz8Sao6+arZKc7jK2QIP2nRhvM0pGNHehor3jdFH2ojA+BbSTr sEnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wRy4gkCiDmjWgFgJgp6H2Spf2zxLT0v4LF/Q/YKKLTU=; b=nTh9s0ZkZ7q9qord3aSFcHPq+750Ses5DIGOVcf8QUEoSlJrf1U867EwJI2LWQzPUP zJqn6DtcyX/4DTwGIP2XYw3wc0UAJeCDAb7fGVY04Kf9trs2Ey7D6t69msY2+/oI45f0 NSr0BEauvWc3PRiz7GKFC3qfd32Omv9TDUcZNpATmWg81pdROyxDdp137MBLfJ+l60CJ P8xBxQFXu6QTyLHc614l8adzKULFltzZ4ogouRtJUiKOVgY0oOVSyveixNHJEfc21med k6ERCvr1VH7gL9fxT2CiPfbDW+Ax7cNy9aiisnWLCNQVo+KR8q6yJ3mkoifmrZcOmHgl gG0A== X-Gm-Message-State: APjAAAWziF70q344Ptyctfl45Wj1hoNlKJ3Kqs1vMSTIXtFmsdbEI0iS EWuTYloEGC9YD1raaMW5G4pvECd4GQg= X-Google-Smtp-Source: APXvYqyKxrZZOzz6+IZ0y/z/qL7nM5qcdy6RrR5vDz39UJAnRXugiU4ewfHfHBrNW0hiU8Pa+E+liA== X-Received: by 2002:a17:90a:340c:: with SMTP id o12mr37240641pjb.18.1574056420215; Sun, 17 Nov 2019 21:53:40 -0800 (PST) Received: from cat-arch.lan (95.246.92.34.bc.googleusercontent.com. [34.92.246.95]) by smtp.gmail.com with ESMTPSA id n62sm19838775pjc.6.2019.11.17.21.53.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Nov 2019 21:53:39 -0800 (PST) From: damenly.su@gmail.com X-Google-Original-From: Damenly_Su@gmx.com To: linux-btrfs@vger.kernel.org Cc: Damenly_Su@gmx.com Subject: [PATCH 1/2] btrfs-progs: block group: do not exclude bytenr adjacent to block group Date: Mon, 18 Nov 2019 13:53:34 +0800 Message-Id: <20191118055335.9927-1-Damenly_Su@gmx.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Su Yue While checking the image provided by the reporter, the btrfsck aborts: ====================================================================== Opening filesystem to check... extent_io.c:158: insert_state: BUG_ON `end < start` triggered, value 1 btrfs check(+0xa3fa8)[0x5614c14c7fa8] btrfs check(+0xa4046)[0x5614c14c8046] btrfs check(+0xa45f1)[0x5614c14c85f1] btrfs check(set_extent_bits+0x83)[0x5614c14c8c63] btrfs check(+0xbfb90)[0x5614c14e3b90] btrfs check(exclude_super_stripes+0x1fc)[0x5614c14e3de9] btrfs check(+0xbd85d)[0x5614c14e185d] btrfs check(btrfs_read_block_groups+0xd3)[0x5614c14e19f5] btrfs check(btrfs_setup_all_roots+0x454)[0x5614c14d7740] btrfs check(+0xb4219)[0x5614c14d8219] btrfs check(open_ctree_fs_info+0x177)[0x5614c14d8415] btrfs check(+0x693dd)[0x5614c148d3dd] btrfs check(+0x14dc7)[0x5614c1438dc7] btrfs check(main+0x126)[0x5614c1439713] /usr/lib/libc.so.6(__libc_start_main+0xf3)[0x7fe3f1ecf153] btrfs check(_start+0x2e)[0x5614c1438cce] [1] 6196 abort (core dumped) ====================================================================== It's excluding super stripes from one block group, the bytenr equals block group's start + len, so the @num_bytes is 0. Then add_exclude_extent() calculates the @end is less than the @start which trigers the abort. Anyway, the logical bytenr should not be excluded if the block group's start + len equals it, because it's not belong to the block group. Link: https://github.com/kdave/btrfs-progs/issues/210 Signed-off-by: Su Yue --- extent-tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extent-tree.c b/extent-tree.c index f690ae999f37..848fb72f90a4 100644 --- a/extent-tree.c +++ b/extent-tree.c @@ -3630,7 +3630,7 @@ int exclude_super_stripes(struct btrfs_fs_info *fs_info, while (nr--) { u64 start, len; - if (logical[nr] > cache->key.objectid + + if (logical[nr] >= cache->key.objectid + cache->key.offset) continue; From patchwork Mon Nov 18 05:53:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 11248897 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C9DB51593 for ; Mon, 18 Nov 2019 05:54:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A9A5F2073A for ; Mon, 18 Nov 2019 05:54:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BC/NIE3w" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726353AbfKRFxo (ORCPT ); Mon, 18 Nov 2019 00:53:44 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:40369 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726168AbfKRFxo (ORCPT ); Mon, 18 Nov 2019 00:53:44 -0500 Received: by mail-pg1-f196.google.com with SMTP id e17so1720181pgd.7 for ; Sun, 17 Nov 2019 21:53:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=a6dIah2qpSX7JdrW3yFwHDO6VBb4FkBSlKIz0MB1VVg=; b=BC/NIE3wtRjlKTwpdnGoKpAhnQAf62F9nTLLtwtNTVMpId05oYyg+ZjUfrN0DkQ1+q 3lBiy11RCHj3KwD0COicXHLi2mQ7mCK5iGCLcVqhrUyJZkB7ERE943pOBUtm3uv+G5g5 zmvysgXGDx7Vx1u6xn5fN+0sGFsRCc8+XVuLPQ10LUOhjjrtRvWX7ltg5qZFhOL82htR jEnkq0Wy7YUgAGpLKCohpjIK2KB8QEk3dUn7n0BwOt7OXu11wmfPyuLJyho33Wn27IBG fAhrApYkNHL/kTcaD4GWPqWEblLn0RXVXc5z52j7TchA6xzB1aCLMGcHYnkjB4IAcW4P Q9Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=a6dIah2qpSX7JdrW3yFwHDO6VBb4FkBSlKIz0MB1VVg=; b=pWnu0DBsOPR6i6bbuBXgPgR3yJYpF2fzxzqtYFDF779GE0sj+NXQ6Zrb0v+uOjSVGZ umfg13O/x/DjFrsfHaPCGyozRR4LTik/244eMh0/mmApW1BRXmgQM5cVkTLowh+nU7b4 TKS4a0cfG152Lj12MUWJ5X7QKsK6vNXwbRR2L37FOJDPdoNoBQU3Bc0x8S6p8Aj4JVHL FQPbS7M3TQQoRU3jrwPsgpBT1jXxKdnSh3lrAY060C2vmUrIamOjqQdqwPocL0rsgGaP OVILcXMW4Iz5wL9b8af4RP+tcl003369eeHstSanQv6Mr1rOszNdIGx0SCHn2QFAfQei eFIw== X-Gm-Message-State: APjAAAXFuXiqdAazt+fskUDnxSIO7ersBu/uhXI7+bza9oq8e3kh5C0H G5hE2gZDpa4I7/4pp9iX34ovs0iBBKI= X-Google-Smtp-Source: APXvYqzCovcXqVow4NVZ+t3W1aqrnrP/wjGy5CCjZ0QeCfIQHmgO7Kj633vZTByMFB8PuLxvpa2Ofw== X-Received: by 2002:a63:6742:: with SMTP id b63mr8276441pgc.24.1574056423244; Sun, 17 Nov 2019 21:53:43 -0800 (PST) Received: from cat-arch.lan (95.246.92.34.bc.googleusercontent.com. [34.92.246.95]) by smtp.gmail.com with ESMTPSA id n62sm19838775pjc.6.2019.11.17.21.53.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Nov 2019 21:53:42 -0800 (PST) From: damenly.su@gmail.com X-Google-Original-From: Damenly_Su@gmx.com To: linux-btrfs@vger.kernel.org Cc: Damenly_Su@gmx.com Subject: [PATCH 2/2] btrfs-progs: fuzz-tests: add image trigers abort of open_ctree() Date: Mon, 18 Nov 2019 13:53:35 +0800 Message-Id: <20191118055335.9927-2-Damenly_Su@gmx.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191118055335.9927-1-Damenly_Su@gmx.com> References: <20191118055335.9927-1-Damenly_Su@gmx.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Su Yue This test case contains a bad block of dev tree and trigers abort while open_ctree() due to its exquisite chunk layout. It can't be repaired by fsck, so put it into fuzz-tests/images. The image is provided by Ruud van Asseldonk. This commit just did xz and writes the record. Link: https://github.com/kdave/btrfs-progs/issues/210 Signed-off-by: Su Yue --- .../images/bad-dev-tree-node.raw.txt | 58 ++++++++++++++++++ .../images/bad-dev-tree-node.raw.xz | Bin 0 -> 18788 bytes 2 files changed, 58 insertions(+) create mode 100644 tests/fuzz-tests/images/bad-dev-tree-node.raw.txt create mode 100644 tests/fuzz-tests/images/bad-dev-tree-node.raw.xz GIT binary patch literal 18788 zcmeHPc{J4h{-24+I+0yyY+1u-lC6;^MAnSP*q4x^$oh;mOLjB1hOvi|ks?b8i6M-& zM3O97AF@P3nA?5sz2`aioZs*M?%exSe&>Aun=}7>&Ut@c@7MSBe!btH_l^?A+yVrm zogS#v-Uot$4}(CUgFWV*6pARVtu+XAZHGcBsG;bbI?H)o+1})Fvcz=3P5RBnNx`sJ zaxE%q;B)1{?Xj^2as@0yA$LB+i?ErFp?O+-Vki7Is#8OlFE_sT*1c$TyXZ~my4Nc{ z55CvVVZz!3(<{)>ub^>PzfWZdC+TH^lcx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