From nobody Sun Apr 30 00:01:42 2023 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 4Q862Z2b4sz48RbR; Sun, 30 Apr 2023 00:01:42 +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 4Q862Z1n7Mz42C8; Sun, 30 Apr 2023 00:01:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682812902; 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=r0IHQCtGgcnNPfpll6FuQqIMY136Q5G1xsI3IVaooGQ=; b=egWeEjMWM1v73IBo9zmaJ0bbaWQPGy94ZRuH6I7qnAe0Z71mbshLuiBO0yEOpZwOzS1Acm B9pvJrnPWGkIoUzLRbt60tupGRdHaZkQtSdeVFOAdJsGg2ANsRuVM9LO5s4W7+y7fFOjFD 4daWEE0TPLNgECvV2NMJbgBjrMLPShAyPsc2luouhToTecHCRZ+Yj0k7V9z79NtDpDoElg cxFrL2D9MzTZc3S6EUAs+wSaEBNDvhS8PHl/oaT7bG08tKQEJEPHAiDrRBBW6UT1jXiFy5 e0JmLiFFFKfAvREdEtRySE1+E6R79BDghfGRRH4Qg/gsMX6yunLivS/K0FlPxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682812902; 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=r0IHQCtGgcnNPfpll6FuQqIMY136Q5G1xsI3IVaooGQ=; b=WF3Jn2ItwLlKBiWsIA7cGX/NSO3gAXBOyg3IV4TItRMTY1RwL0PHbBxH+RunHNZBT3W1dl 7FSqGAmgu8yXs0cH/STtILWT7XYpc0PndN1mIJ9zO4ZJRpo2rbk6H4yDAh7LYkyMHgFj6M mmyJEFhxhcxIKlMnHizr7qxIqf86FH1ipkrsouoSvCOCR42UYEhaIXfkrg7DVQA8kOuFTG Z4X/+PHrtfF1oDIec2blBt7QS+tbS+e0fu5v2aBPEzw95Jy7wqwqjSIxVCH1hxY500ifn7 UoR3Ndb7JAKIpTFiOZnXHlmiK0a5eQlVEd8/I6gv0qAUwlJvr7EMYA33p9QxpA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1682812902; a=rsa-sha256; cv=none; b=HyPkEPhJZhGT9jeTrb7OM09Gl7UP0dO7CnQlBftssTfjEw+bLg0xJCbkGjUM8StRHPhYKr LOonyXidOX7rMjPR+sFLSubV6F9jPtHXuE27boA//3H/lHK6dRZ/d2WN6FPlIBz1yvN1ey +kkA8qX/WV1Px/NElaWUgLEKIhREGs51ryxCN7HyM2qDC9IwlGX/T+9dZDI5rofGbvAqFl 74yVkA5wYT+dlGX+c6gbhakcxQJLtEVIM4e4jGIi+IpGMqCfz3nQmFO6BAj0wG0Ksp/OnW 9NpHPj6f9CJqEJN79JftQ8YHbOWEmxnQRaZqCGcocNRI/KSCymc9fWX46UqTmw== 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 4Q862Z0t2Lz12C0; Sun, 30 Apr 2023 00:01:42 +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 33U01gx0090405; Sun, 30 Apr 2023 00:01:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33U01gZS090404; Sun, 30 Apr 2023 00:01:42 GMT (envelope-from git) Date: Sun, 30 Apr 2023 00:01:42 GMT Message-Id: <202304300001.33U01gZS090404@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: 62dc21b10731 - main - Additional validity checking in newfs(8). 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: 62dc21b10731bdba26dafeb51640c2048a3344a0 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=62dc21b10731bdba26dafeb51640c2048a3344a0 commit 62dc21b10731bdba26dafeb51640c2048a3344a0 Author: Kirk McKusick AuthorDate: 2023-04-29 19:49:50 +0000 Commit: Kirk McKusick CommitDate: 2023-04-30 00:01:18 +0000 Additional validity checking in newfs(8). A check in the superblock validity code verifies that the computed size of the filesystem cylinder groups (CGSIZE macro) does not exceed the filesystem block size (fs_bsize). A report was received that a filesystem had been flagged as failing this check. We were unable to determine how the reported filesystem could have been created. This commit adds a check at the end of the newfs(8) command to verify that the the cylinder group size is valid. If an oversize cylinder group is found newfs(8) prints a diagnostic output and rebuilds the filesystem to make it compiliant. MFC after: 1 week --- sbin/newfs/mkfs.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c index 16508305aa57..5af121104821 100644 --- a/sbin/newfs/mkfs.c +++ b/sbin/newfs/mkfs.c @@ -332,6 +332,7 @@ restart: * can put into each cylinder group. If this is too big, we reduce * the density until it fits. */ +retry: maxinum = (((int64_t)(1)) << 32) - INOPB(&sblock); minfragsperinode = 1 + fssize / maxinum; if (density == 0) { @@ -666,6 +667,21 @@ restart: pp->p_frag = sblock.fs_frag; pp->p_cpg = sblock.fs_fpg; } + /* + * This should NOT happen. If it does complain loudly and + * take evasive action. + */ + if ((int32_t)CGSIZE(&sblock) > sblock.fs_bsize) { + printf("INTERNAL ERROR: ipg %d, fpg %d, contigsumsize %d, ", + sblock.fs_ipg, sblock.fs_fpg, sblock.fs_contigsumsize); + printf("old_cpg %d, size_cg %jd, CGSIZE %jd\n", + sblock.fs_old_cpg, sizeof(struct cg), CGSIZE(&sblock)); + printf("Please file a FreeBSD bug report and include this " + "output\n"); + maxblkspercg = fragstoblks(&sblock, sblock.fs_fpg) - 1; + density = 0; + goto retry; + } } /*