From: Darrick J. Wong Date: Thu, 4 Jun 2026 06:05:54 +0000 (-0700) Subject: xfs_scrub: fix integer overflows X-Git-Tag: v7.1.0~61 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a42fc3ec97db903c5dc4493203b29d629136a0e5;p=xfsprogs-dev.git xfs_scrub: fix integer overflows agblocks is a 32-bit variable, which means that on a filesystem with a large AG block count (e.g. 2^31 blocks on a 1k fsblock fs) the multiplication with 95 could cause an integer overflow. Let's just do 64-bit arithmetic here. Codex found this. Cc: linux-xfs@vger.kernel.org # v6.10.0 Fixes: 34bed605490f93 ("xfs_scrub: tune fstrim minlen parameter based on free space histograms") Signed-off-by: "Darrick J. Wong" Reviewed-by: Andrey Albershteyn --- diff --git a/scrub/phase8.c b/scrub/phase8.c index 0967832d..5bfe0ffb 100644 --- a/scrub/phase8.c +++ b/scrub/phase8.c @@ -149,7 +149,7 @@ fstrim_compute_minlen( * We can't calculate or query that value directly, so we guesstimate * that it's 95% of the AG size. */ - ag_max_usable = ctx->mnt.fsgeom.agblocks * 95 / 100; + ag_max_usable = (uint64_t)ctx->mnt.fsgeom.agblocks * 95 / 100; if (debug > 1) { struct histogram_strings hstr = {