From nobody Thu Nov 17 22:51:52 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NCwCD3jHgz4hPWd; Thu, 17 Nov 2022 22:51:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NCwCD3JTKz3NFv; Thu, 17 Nov 2022 22:51:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668725512; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Qatpdczu5mGy2PcDU4N8j8Pfij3CKyqPjaYVZivj6wo=; b=ZQPgrB9nVF8nfYXDzVzMytg9WaY3ssWZU1XUruWXFjIdW2tyGMx/NPLU8WA6RgfLUfX64Y fDkkxnnlmWMVrClcIWEe42JMnPklRa6XO3mgZ58c6Mtro/TRTP6tsfs5ESCFrPEREljMVq tmo6PDP3rYKrxFbWZ16EeAK9ocaRDly5+2AYhiRS3Fq5inzfgDWr2aBCNFQbhe2NQjVFtu JLlx3I9+eLoUUDfhF66F7lbONcaGvzCqXmLHek5y9bCNyl6a3ANU9+2hIQ0zHJF5D5AVw1 RDIGN84gOjPypFzAq3yQokWLWlGsnxrDTI4xaq/9cECKWQMZG9eWUnLj5nTuEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668725512; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Qatpdczu5mGy2PcDU4N8j8Pfij3CKyqPjaYVZivj6wo=; b=negVNYttSUJuBA4lLI0ACqQgG1P7orF1V7FUv1pZKTI4ci9ifGg8hGXPr4dBw338bd35EH L+37QD7XsY0tVyI2U32xJMa7ZSjQfXezJzlMb3wzq6pQMEQFQtJs6gXNcww3wdYPc3dsxf Xdg36zsFxtgTMrLwrL6IImSsc9PMG+aX44HZ3t75FnsOiZRCjVBkNj0fM6Lk4ple2Qyk9t qpifdclfn/j9NV1i/sLffh8tSwu46YSzz207VirZ+e1gFPFcCdJAgdUhHv3PDHSApRNoTE vmznJgaDywiVeYS7gxx7cn8zajLXt1gKd/Vfi32LJ+/TyCx2aNs7FSlhcyshOA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1668725512; a=rsa-sha256; cv=none; b=ccguke1R3nF6ySBLOZdygZyZqYZAcCqfSThM1ZeNCGDs3355xshXJXAxWqz+2r26MTYkdg 7NAYjSNDAi4gvFhdl/g++r39WWIrsE3iMyE/DBEkIwIJrIhSCqEhwODFa5az5lfz6SQMPK jk7hMBg/tA+3uEVBb8ZbTxrg/De04u5LBokC5rFdOwp1Mqj+ZDIaoFzCfTijnPbpWfDmvm YgC4wS3OegXNl8HYEDzV/pFl4ojalN63sp2/Jq8mUosVcQdqzjuckHBLrGHItlarU8qRWy tvQv0CVyaDSShovy6N9Nkx7zFW2ptfsBy+g3cULZphzLhiQk3qL8ngG7+rADjw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NCwCD2NDnzyrF; Thu, 17 Nov 2022 22:51:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2AHMpqoI061304; Thu, 17 Nov 2022 22:51:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AHMpqnZ061303; Thu, 17 Nov 2022 22:51:52 GMT (envelope-from git) Date: Thu, 17 Nov 2022 22:51:52 GMT Message-Id: <202211172251.2AHMpqnZ061303@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kirk McKusick Subject: git: 8435a9b20684 - main - Updates to UFS/FFS superblock integrity checks when reading a superblock. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mckusick X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8435a9b20684ba8bcda3df31d06b4d5eac9431a7 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=8435a9b20684ba8bcda3df31d06b4d5eac9431a7 commit 8435a9b20684ba8bcda3df31d06b4d5eac9431a7 Author: Kirk McKusick AuthorDate: 2022-11-17 22:50:27 +0000 Commit: Kirk McKusick CommitDate: 2022-11-17 22:51:15 +0000 Updates to UFS/FFS superblock integrity checks when reading a superblock. Further updates adding casts to avoid 32-bit multiplication overflow inspired by fixes in commit 017367c1146a69. No legitimate superblocks should fail as a result of these changes. Sponsored by: The FreeBSD Foundation --- sys/ufs/ffs/ffs_subr.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/ufs/ffs/ffs_subr.c b/sys/ufs/ffs/ffs_subr.c index b6b0be56fc73..67f4fcd92fd8 100644 --- a/sys/ufs/ffs/ffs_subr.c +++ b/sys/ufs/ffs/ffs_subr.c @@ -473,13 +473,15 @@ validate_sblock(struct fs *fs, int flags) FCHK(fs->fs_fpg, <, 3 * fs->fs_frag, %jd); FCHK(fs->fs_ncg, <, 1, %jd); FCHK(fs->fs_ipg, <, fs->fs_inopb, %jd); - FCHK(fs->fs_ipg * fs->fs_ncg, >, (((int64_t)(1)) << 32) - INOPB(fs), - %jd); + FCHK((u_int64_t)fs->fs_ipg * fs->fs_ncg, >, + (((int64_t)(1)) << 32) - INOPB(fs), %jd); FCHK(fs->fs_cstotal.cs_nifree, <, 0, %jd); - FCHK(fs->fs_cstotal.cs_nifree, >, fs->fs_ipg * fs->fs_ncg, %jd); + FCHK(fs->fs_cstotal.cs_nifree, >, (u_int64_t)fs->fs_ipg * fs->fs_ncg, + %jd); FCHK(fs->fs_cstotal.cs_ndir, <, 0, %jd); FCHK(fs->fs_cstotal.cs_ndir, >, - (fs->fs_ipg * fs->fs_ncg) - fs->fs_cstotal.cs_nifree, %jd); + ((u_int64_t)fs->fs_ipg * fs->fs_ncg) - fs->fs_cstotal.cs_nifree, + %jd); FCHK(fs->fs_sbsize, >, SBLOCKSIZE, %jd); FCHK(fs->fs_sbsize, <, (signed)sizeof(struct fs), %jd); FCHK(fs->fs_maxbsize, <, fs->fs_bsize, %jd);