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>
* 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 = {