git: 017367c1146a - main - ffs validate_sblock(): avoid 32bit mul overflow

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Thu, 27 Oct 2022 03:20:32 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=017367c1146a69baca6a1a0bea10b0cb02c72d85

commit 017367c1146a69baca6a1a0bea10b0cb02c72d85
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-10-24 21:34:15 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-10-27 03:17:38 +0000

    ffs validate_sblock(): avoid 32bit mul overflow
    
    Reported by:    soralx@cydem.org
    Tested by:      pho
    Reviewed by:    mckusick
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
---
 sys/ufs/ffs/ffs_subr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/ufs/ffs/ffs_subr.c b/sys/ufs/ffs/ffs_subr.c
index e804dfa3d330..b6b0be56fc73 100644
--- a/sys/ufs/ffs/ffs_subr.c
+++ b/sys/ufs/ffs/ffs_subr.c
@@ -546,8 +546,8 @@ validate_sblock(struct fs *fs, int flags)
 	 * and ends in the data area of the same cylinder group.
 	 */
 	FCHK(fs->fs_size, <, 8 * fs->fs_frag, %jd);
-	FCHK(fs->fs_size, <=, (fs->fs_ncg - 1) * fs->fs_fpg, %jd);
-	FCHK(fs->fs_size, >, fs->fs_ncg * fs->fs_fpg, %jd);
+	FCHK(fs->fs_size, <=, ((int64_t)fs->fs_ncg - 1) * fs->fs_fpg, %jd);
+	FCHK(fs->fs_size, >, (int64_t)fs->fs_ncg * fs->fs_fpg, %jd);
 	/*
 	 * If we are not requested to read in the csum data stop here
 	 * as the correctness of the remaining values is only important