]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
xfs_scrub: fix integer overflows
authorDarrick J. Wong <djwong@kernel.org>
Thu, 4 Jun 2026 06:05:54 +0000 (23:05 -0700)
committerAndrey Albershteyn <aalbersh@kernel.org>
Thu, 11 Jun 2026 10:26:04 +0000 (12:26 +0200)
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" <djwong@kernel.org>
Reviewed-by: Andrey Albershteyn <aalbersh@kernel.org>
scrub/phase8.c

index 0967832da890e3f2bc7849f8632b724bcfaa0ea2..5bfe0ffb4868a2293d78dfd6c6afde4d917de383 100644 (file)
@@ -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 = {