Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3803352rdb; Thu, 14 Sep 2023 03:12:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEhjG9dXjEU9zoJDYR2+yxn0gaKyxwBPtTiEshbL16VIxEe2xZ98VB/3+KAFMQTEjR06whk X-Received: by 2002:a17:903:22cb:b0:1c1:fc5c:b34a with SMTP id y11-20020a17090322cb00b001c1fc5cb34amr5649123plg.3.1694686371188; Thu, 14 Sep 2023 03:12:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694686371; cv=none; d=google.com; s=arc-20160816; b=fJ7bIrKxr7VY0ttW+sxR8MqQmbG0Dv4n1JVwb2PBSmdZY6AcmFn61j7ilhhjclj+kW RJ7OWArngdMe4QXiM8eTgbrXPkc/ZncFEIIFX1iEH7R7z4xVPnnTr+fRfGCfmeyiwsHp 5zshQFlvs4l9S1LsSXEL60rmfFuMSTh0Co+c+7THDDHfbJO4nOI5WRjl+pegZ7VDjD5E hsGfDXG6Ofshp0X8Eapb0y7aH+LJB7B3uRJBbdztusI1feiFPNfFp4LwdJck9WniEZf6 hOC6BZy6pkgZ177QRkPCY3yC7clPZdo1U8d1DQYHCdGkVWLbl3+/ZC1XCBPIJRfQshnB A0Yg== 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 :message-id:date:subject:cc:to:from; bh=7+BWJl7jUbw18j6mRQMSjiiIIn0v1G/Viynwc1dBORE=; fh=uGgBrLNQNf7Vbe71oX97SpxO5j29DZHNnULPFgpE9hA=; b=QD8y+Ys5s6SW6U/2eekYFwNw83/Q7DJBlGndgjyFBpRNImeuatpWC18nkO6hxqUTVj vMhNp/bwZIWYblMcjrnLkt1pTAWyF6kzDd5nMJ7z8+yCsyhQcLroFCrCdO30ZIRkuHhN AtpHRwGlRehQnDnhGd8xhx7FX+XuosRU459NS5WmGJCRdMmpUsw2qYZvwADqwM22g8Y/ Bwn9Uh8XmnEZ8LVee8gXGoe/YtvOqJMszAAlKY/hzLUc5ddr1WPeghU19QOwpdHHRw06 K8Vm6czpfo4wEp8nvXx/NZMREHR4vAF4PMwLGaA1O0Nqz9yte64KnjYmk7TvKCUbFtUj B5mA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id l8-20020a170903244800b001bf5c12ea06si1434266pls.404.2023.09.14.03.12.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 03:12:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 5ABDF801D748; Thu, 14 Sep 2023 02:46:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237465AbjINJqr (ORCPT + 99 others); Thu, 14 Sep 2023 05:46:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237761AbjINJq0 (ORCPT ); Thu, 14 Sep 2023 05:46:26 -0400 Received: from mail.astralinux.ru (mail.astralinux.ru [217.74.38.119]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 907201FC6; Thu, 14 Sep 2023 02:46:20 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id B0F9F1864859; Thu, 14 Sep 2023 12:46:16 +0300 (MSK) Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 21PzqHuNWfIK; Thu, 14 Sep 2023 12:46:16 +0300 (MSK) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id 6A54A186337A; Thu, 14 Sep 2023 12:46:16 +0300 (MSK) X-Virus-Scanned: amavisd-new at astralinux.ru Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Bf6bOSsUcO7o; Thu, 14 Sep 2023 12:46:16 +0300 (MSK) Received: from rbta-msk-lt-106062.astralinux.ru (unknown [10.177.13.132]) by mail.astralinux.ru (Postfix) with ESMTPSA id 34B591864965; Thu, 14 Sep 2023 12:46:15 +0300 (MSK) From: Anastasia Belova To: Chris Mason Cc: Anastasia Belova , Josef Bacik , David Sterba , Dennis Zhou , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, Greg Kroah-Hartman , stable@vger.kernel.org Subject: [PATCH 5.10] btrfs: fix region size in count_bitmap_extents Date: Thu, 14 Sep 2023 12:45:55 +0300 Message-Id: <20230914094555.25657-1-abelova@astralinux.ru> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 14 Sep 2023 02:46:53 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email count_bitmap_extents was deleted in version 5.11, but there is possible mistake in versions 5.6-5.10. Region size should be calculated by subtracting the end from the beginning. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: dfb79ddb130e ("btrfs: track discardable extents for async discard"= ) Signed-off-by: Anastasia Belova --- fs/btrfs/free-space-cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 4989c60b1df9..a34e266a0969 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -1930,7 +1930,7 @@ static int count_bitmap_extents(struct btrfs_free_s= pace_ctl *ctl, =20 bitmap_for_each_set_region(bitmap_info->bitmap, rs, re, 0, BITS_PER_BITMAP) { - bytes -=3D (rs - re) * ctl->unit; + bytes -=3D (re - rs) * ctl->unit; count++; =20 if (!bytes) --=20 2.30.2