Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1578044lqp; Fri, 22 Mar 2024 23:26:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX9uIdJZoUlJeexmroKQs8dk53efPrnng2C53mj+KKU18jnNg2ZCKSGoEvG9zUxo1ySBDAXObgKXLUFHtf6DEMNebsKwdzzPLK6Clz+qg== X-Google-Smtp-Source: AGHT+IHcKiwQinidRQjGMwh6jz7uWSrfMnjtd3f8TVTc2kgG6jQKRZwgOWP6FwVSMEvo6SHNE6Pz X-Received: by 2002:ac2:5b44:0:b0:515:8bde:56c3 with SMTP id i4-20020ac25b44000000b005158bde56c3mr1038298lfp.26.1711175192556; Fri, 22 Mar 2024 23:26:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711175192; cv=pass; d=google.com; s=arc-20160816; b=zogC/DdtCubapRMuqFA7NErNPhVOGC19T4ZtkMeG8sGVTsFS8xdgsikJXTi1LHFErO HkHhFy1JiMZwQL4wwgkVgBWU295C84fF8aGhOqa/9eYEH7gHi1/RrqNa/u9AAGQwDS5d h8BRWBMhUlyECNgKqr+I6enAzhhZpdctp/YQLA0Bq5Cts6XM8QOjsjQbKsMUeL139MAO OaCg8ZFNZB0N2Cypaz4XjyupvYYdlfDeSJbyMwnj0xQvEKSL0o2TFxxPdu3n9/3IMqp5 fCbZhzkqAgBrhnygSt9n6aGw44ysNtZhp7/SUfkwG9uJwXHANHkC+mOKmUu0GmRwwlz0 4f9Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=qB6BJAh0IUhSZxgXq667+NZUhFp8g74YHpa6+zfLqd8=; fh=quFmJLOXU1MTLVfwKyKIG0qtqu3J4pUUAXy5isifWnE=; b=n0VmEYd6Q/frEwUHoAjrQE6+eGFFxCRIVpaDnufpctECgEW0bT5u3Vw3HYOSO8m/se Bat/raELrK4Mvr6qYN0BqWMEXEr+rlrks1OaNNSmVKp1DjuGE6zr99c3ueTRswWiyfBT q9QxfnRbRcUMh83bLt9CZhzqMkesBMpkJnW9tKt5i+1f2LdUdq8B1bChYFmsYfysT9Aa OeoscP7PWV/5vv7dJqOxy1+4+WDNmZnnUqDNkWms0VQFV83r+1ru9t6Phz1zj+Ez0PlL umxdLjug6KlBLxFbOujfBszrfobUm7dpQNj+AfH0ioxw0GcznRg7P24iRneKnAa4CMEq 23DA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nppct.ru header.s=dkim header.b="otvaLSl/"; arc=pass (i=1 spf=pass spfdomain=nppct.ru dkim=pass dkdomain=nppct.ru); spf=pass (google.com: domain of linux-kernel+bounces-112232-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112232-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id el10-20020a056402360a00b0056bb2c5dbd8si565733edb.74.2024.03.22.23.26.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 23:26:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112232-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@nppct.ru header.s=dkim header.b="otvaLSl/"; arc=pass (i=1 spf=pass spfdomain=nppct.ru dkim=pass dkdomain=nppct.ru); spf=pass (google.com: domain of linux-kernel+bounces-112232-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112232-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 476701F219BD for ; Sat, 23 Mar 2024 06:26:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 46BB36107; Sat, 23 Mar 2024 06:26:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nppct.ru header.i=@nppct.ru header.b="otvaLSl/" Received: from mail.nppct.ru (mail.nppct.ru [195.133.245.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 972CF5382 for ; Sat, 23 Mar 2024 06:26:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.133.245.4 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711175183; cv=none; b=scu5S7RyCKM6s8FVbu9KTzg4xUVZ0Wln9vz5301jQT0WMW/i71Xo7Sdae6m4Kn1quV/Jo7oChdcceGeTWq54b9nCqtLpZbS/x5o/XWj+jcGYtUFCV1S/J3t8dhOlvz02sh589fzG4gp9mHxXiYNGMbMzTN3Ob0yG+44dDuOhHws= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711175183; c=relaxed/simple; bh=4zNnlz2FX5Z0fSGTzKMLqhTxCPDwK2SwGj0Ql4edVXg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=A8ckKcjUBUhEpSoOLEIoMRciWEOWkLupPwkCTzK5mE+9jxJd373aZ9K6CRDF3gQdk9O4Rmg/6Rts/aSZmiiFZLC+rLcffiiUOOyz+RDdyJL13qz0UYFZyOuRcpLqltodP62o1FKsL4wWwybbsdRFuzhcjed6Q47UjiBWwzjdmQk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nppct.ru; spf=pass smtp.mailfrom=nppct.ru; dkim=pass (1024-bit key) header.d=nppct.ru header.i=@nppct.ru header.b=otvaLSl/; arc=none smtp.client-ip=195.133.245.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nppct.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nppct.ru Received: from mail.nppct.ru (localhost [127.0.0.1]) by mail.nppct.ru (Postfix) with ESMTP id B584E1C14F7 for ; Sat, 23 Mar 2024 09:26:12 +0300 (MSK) Authentication-Results: mail.nppct.ru (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=nppct.ru DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nppct.ru; h= content-transfer-encoding:mime-version:x-mailer:message-id:date :date:subject:subject:to:from:from; s=dkim; t=1711175172; x= 1712039173; bh=4zNnlz2FX5Z0fSGTzKMLqhTxCPDwK2SwGj0Ql4edVXg=; b=o tvaLSl/V2pZzlQTLKiVsEA3KVKG0jOlQAu3iDTYeqOkpo0Qy9iPD/VFLTLw8n+Bj ahw1mvAcmg1p8G9masa1Q63a7SaSnz+CRwG5bg3JDgwu8RnEoaD0Qhsk9iHE/WY8 /Ie+/wTTcGPrD4aDaI6o6sDwxZfe77kAJklShNQDmI= X-Virus-Scanned: Debian amavisd-new at mail.nppct.ru Received: from mail.nppct.ru ([127.0.0.1]) by mail.nppct.ru (mail.nppct.ru [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Zh1y3rhpW_ki for ; Sat, 23 Mar 2024 09:26:12 +0300 (MSK) Received: from localhost.localdomain (mail.dev-ai-melanoma.ru [185.130.227.204]) by mail.nppct.ru (Postfix) with ESMTPSA id 22CE71C129D; Sat, 23 Mar 2024 09:26:10 +0300 (MSK) From: Andrey Shumilin To: Chandan Babu R Cc: Andrey Shumilin , "Darrick J. Wong" , Dave Chinner , linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org (open list), lvc-project@linuxtesting.org, khoroshilov@ispras.ru, ykarpov@ispras.ru, vmerzlyakov@ispras.ru, vefanov@ispras.ru Subject: [PATCH 2/2] xfs_refcount: Preventing integer overflow Date: Sat, 23 Mar 2024 09:26:03 +0300 Message-Id: <20240323062603.665572-1-shum.sdl@nppct.ru> X-Mailer: git-send-email 2.30.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Multiplying variables can overflow the "overhead" variable. To fix this, the variable type has been increased. Next, a subtraction operation occurs with it, but before that it is checked. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Andrey Shumilin --- fs/xfs/libxfs/xfs_refcount.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c index 511c912d515c..cbf07552eaff 100644 --- a/fs/xfs/libxfs/xfs_refcount.c +++ b/fs/xfs/libxfs/xfs_refcount.c @@ -1070,7 +1070,7 @@ static bool xfs_refcount_still_have_space( struct xfs_btree_cur *cur) { - unsigned long overhead; + unsigned long long overhead; /* * Worst case estimate: full splits of the free space and rmap btrees -- 2.30.2