From nobody Thu Jul 21 05:52:42 2022 X-Original-To: dev-commits-src-main@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 4LpMDB5X5Tz4WkH9; Thu, 21 Jul 2022 05:52: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 4LpMDB4rdvz3MPh; Thu, 21 Jul 2022 05:52:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658382762; 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=MXGJp1m4Wi2QZtsBZHsdkgaIe7okZLgwYyLq01eAFSo=; b=k7mt4UeSXc5unMoR5PS+isYAj2B4hdE1mhYLlNLUaoGvqjQsRkT8a4WcbTeeLm2Jwno+dC OPU5XnCbVw7mEiT1l+fzF0cRxzFTw2G4ImTaQg/IWWcPPyIH/8QXY6D5/ORAz0/abfSMEC uKqtT+XxGdm66xHThG/iYw0b58OrBFIjjzmwuNCnUgVv0iseG6pXarEj1eWdm4Yn+mEzTO iFdXgXTuCX9AGgycXtr7TP90bZkCIdQqNssMiCs33B0QT7sl3DVA+U3Npaa9551/xkH3sd OX2XpYGkgrIBlcbw7uNL9Yj7LQXl+1tnp2Yxf3hRUxNlyj8LYClNUcQUiRyHhA== 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 4LpMDB3sStz1Q3l; Thu, 21 Jul 2022 05:52: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 26L5qgXi065955; Thu, 21 Jul 2022 05:52:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26L5qg6g065954; Thu, 21 Jul 2022 05:52:42 GMT (envelope-from git) Date: Thu, 21 Jul 2022 05:52:42 GMT Message-Id: <202207210552.26L5qg6g065954@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: 36e08b0127f9 - main - Bug fix to UFS/FFS superblock integrity checks when reading a superblock. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: 36e08b0127f97928a2f2c062feed8df9087b2b35 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658382762; 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=MXGJp1m4Wi2QZtsBZHsdkgaIe7okZLgwYyLq01eAFSo=; b=covDkRpWZxJ9LkllBm950kqk1HK5ZfrzAxauOduvVpl6AnLHlrJM9CCRyjmXSoEJ5Xvq4n lzY5EaXoBOrPvl+F6A0Qtl9wwFlL0HiEF9k6C0gtbogjjBko3lQFZ43QFl+qP/+QGH70gk NtSccGkI7OvcnP1nBRWa7hdvj3uneAgCSUtMfPExHmINGYTdpqX2/EThqDR/YtZK3gUL3a wK0aaxd9m8ptWdzIDKSnHopUI4li7rX0IEjsx8QvsXjZiH744GkqIPnlxCcu+O7/4uqpT3 UhYjIKUIk8neA1mjDY5Nzk+BIETUMooMKWiLJv7q8Vc762daHvxT5ld2bokndw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658382762; a=rsa-sha256; cv=none; b=Epn5C81n4nwwr42JX0+eHgvg0w5DLFJFliXG5Cf0I/2MNO3d2ZWC4IFxYS3Qrw6gTDt0QV NNFeUiqofQUEUuOvoO8EqTnPTVJXebtSN9xkMhwNEKJyrg30LHaw6cKDEfRbwP2PiAtmO3 B+MUMXoXgBYGisTlFdi5oqFk56ivS2v0kppdIDWa+LscEPryYCaNNIfymyVmR9iSv8oKmR EM1wm6slRD9hh4Dsn50TGU40JMm26aSrmrimY+7+0+ZqDQH9qXskhsiRNI/+N0HMaV5Abc uhK+46yKgWP0cDEbHbMrzTX8XDMsi487BldevVDlMjvbBSmnIlCpYH2JFSwzHQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=36e08b0127f97928a2f2c062feed8df9087b2b35 commit 36e08b0127f97928a2f2c062feed8df9087b2b35 Author: Kirk McKusick AuthorDate: 2022-07-21 05:51:15 +0000 Commit: Kirk McKusick CommitDate: 2022-07-21 05:52:11 +0000 Bug fix to UFS/FFS superblock integrity checks when reading a superblock. A better fix to commit 9e1f44d044a. Rather than coping with the case where a backup superblock is used, catch the case when the superblock is being read in and ensure that the standard one is used rather than the backup one. --- sys/ufs/ffs/ffs_subr.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/sys/ufs/ffs/ffs_subr.c b/sys/ufs/ffs/ffs_subr.c index 21daa44de4d8..1df3f878c4eb 100644 --- a/sys/ufs/ffs/ffs_subr.c +++ b/sys/ufs/ffs/ffs_subr.c @@ -256,6 +256,16 @@ readsuper(void *devfd, struct fs **fsp, off_t sblockloc, int isaltsblk, fs = *fsp; if (fs->fs_magic == FS_BAD_MAGIC) return (EINVAL); + /* + * For UFS1 with a 65536 block size, the first backup superblock + * is at the same location as the UFS2 superblock. Since SBLOCK_UFS2 + * is the first location checked, the first backup is the superblock + * that will be accessed. Here we fail the lookup so that we can + * retry with the correct location for the UFS1 superblock. + */ + if (fs->fs_magic == FS_UFS1_MAGIC && !isaltsblk && + fs->fs_bsize == SBLOCK_UFS2 && sblockloc == SBLOCK_UFS2) + return (ENOENT); if ((error = validate_sblock(fs, isaltsblk)) != 0) return (error); /* @@ -349,20 +359,7 @@ validate_sblock(struct fs *fs, int isaltsblk) } else if (fs->fs_magic == FS_UFS1_MAGIC) { if (!isaltsblk) { CHK(fs->fs_sblockloc, >, SBLOCK_UFS1, %jd); - /* - * For UFS1 the with a 65536 block size, the first - * backup superblock is at the same location as the - * UFS2 superblock. Since SBLOCK_UFS2 is the first - * location checked, the first backup is the - * superblock that will be accessed. - */ - if (fs->fs_bsize == SBLOCK_UFS2) { - CHK(fs->fs_sblockactualloc, >, SBLOCK_UFS2, - %jd); - } else { - CHK2(fs->fs_sblockactualloc, !=, SBLOCK_UFS1, - fs->fs_sblockactualloc, !=, 0, %jd); - } + CHK(fs->fs_sblockactualloc, >, SBLOCK_UFS1, %jd); } CHK(fs->fs_nindir, !=, fs->fs_bsize / sizeof(ufs1_daddr_t), %jd);