From patchwork Fri Apr 28 09:50:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe de Dinechin X-Patchwork-Id: 9704341 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 D3B72602B7 for ; Fri, 28 Apr 2017 09:50:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C498D280CF for ; Fri, 28 Apr 2017 09:50:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B7C2D28667; Fri, 28 Apr 2017 09:50:30 +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 4C156280CF for ; Fri, 28 Apr 2017 09:50:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423460AbdD1Ju3 convert rfc822-to-8bit (ORCPT ); Fri, 28 Apr 2017 05:50:29 -0400 Received: from mail-wr0-f171.google.com ([209.85.128.171]:33540 "EHLO mail-wr0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164560AbdD1Ju0 (ORCPT ); Fri, 28 Apr 2017 05:50:26 -0400 Received: by mail-wr0-f171.google.com with SMTP id w50so30789254wrc.0 for ; Fri, 28 Apr 2017 02:50:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=slPjQCg3c2KgkDlPhpeJZFNkQC9DSE7p9y4hyl2OSeg=; b=QsEr9QRtBxRzmevQ6W+KQ30uHpULmWXuiB0kbAGZUSQDgtLjiX3BdG0HFc+JSY/arU RQpak1G26MukxbCPejK0nzpv6Ap1F0gXwiUaLiY9Ph8CNCTT9ShH+75EEfLvYLPqAZ2O G/nN5Tza3dDs6TPqOU7MUg47fB/gPNpBX+Lvb9F0rShwE+nIlQGkgAgMNrLwftbiqD1n rnpySzbwbAKopymFoQQIR9am8Auz3zccDA2yYpOctdzerV/LcBpD/3aEDTCfatU+kBtG EVyay7P0IJNCLbxuu8sYZlULL5YBrOK89VkL4/+Q/i/RQ0FGXRhGcnOX8LEatWuhOZ2o DgtA== X-Gm-Message-State: AN3rC/4AoldADAMRyTIt4Tx0J/WjKXVV7RWsdZERLXPECcfEg/lKuUDe E+VZJTNmc/BUJReZ+tgcow== X-Received: by 10.223.164.153 with SMTP id g25mr6669308wrb.103.1493373025229; Fri, 28 Apr 2017 02:50:25 -0700 (PDT) Received: from [192.168.77.22] (val06-1-88-182-161-34.fbx.proxad.net. [88.182.161.34]) by smtp.gmail.com with ESMTPSA id 23sm7056058wrx.26.2017.04.28.02.50.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Apr 2017 02:50:24 -0700 (PDT) Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Subject: [PATCH 2/3 v2] Prevent attempt to insert extent record with max_size==0 From: Christophe de Dinechin In-Reply-To: <20170428141640.12429352@natsu> Date: Fri, 28 Apr 2017 11:50:23 +0200 Cc: Roman Mamedov Message-Id: <74CAC383-4C3A-4C68-9B56-2AB28947E3E3@redhat.com> References: <004EF35C-BB29-4B53-8BEC-B0DB38F0A301@redhat.com> <20170428141640.12429352@natsu> To: Btrfs BTRFS X-Mailer: Apple Mail (2.3273) 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 When this happens, we will trip a BUG_ON(end < start) in insert_state because in check_extent_refs, we use this max_size expecting it's not zero: set_extent_dirty(root->fs_info->excluded_extents, rec->start, rec->start + rec->max_size - 1); See https://bugzilla.redhat.com/show_bug.cgi?id=1435567 for an example where this scenario occurs. Signed-off-by: Christophe de Dinechin --- cmds-check.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cmds-check.c b/cmds-check.c index 2d3ebc1..c13f900 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -6029,6 +6029,7 @@ static int add_extent_rec_nolookup(struct cache_tree *extent_cache, struct extent_record *rec; int ret = 0; + BUG_ON(tmpl->max_size == 0); rec = malloc(sizeof(*rec)); if (!rec) return -ENOMEM;