From nobody Wed Jul 06 21:45:57 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 0F5F11D1412A; Wed, 6 Jul 2022 21:45:58 +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 4LdY513jZxz4Zrk; Wed, 6 Jul 2022 21:45:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657143957; 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=ujEtXG/eJZp4keKRIQWtaOjbOhAMagIw+TtCv1yrnaw=; b=bayhuZYinvoqEDfktxEemsUEe2yK256l5e8xA2WnrDyeViVGedEBxoT26Vc90Npa+emwGI jrTkX/Utszh2Mr7ydPn6aJv7sFAQ3dACxEn6B5x2kUqEK2Vu2GxOOj1AJ6C+B2QtpIJjSx G34q4kHaFRHOUM6GDNX4Zg6bMW6zJlYf4cTnixp99FU146C8FN8SBuIpUZ91DijZvBwdnZ w1k8aW1SIzEt7JiMhJBMkuxFqv8/87WBN06V3/XQyj2baXKg5z8QHwET+Kvpjo4RGO5MEB PzI6gVqAtL/KISxMVkVLjR6Pr1/83RN8SL9hLSdWLbNBJZrn6HVMGXJoYycXLg== 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 5658A2273C; Wed, 6 Jul 2022 21:45:57 +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 266LjvYp064291; Wed, 6 Jul 2022 21:45:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 266Ljvs7064290; Wed, 6 Jul 2022 21:45:57 GMT (envelope-from git) Date: Wed, 6 Jul 2022 21:45:57 GMT Message-Id: <202207062145.266Ljvs7064290@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: 9e1f44d044a5 - 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: 9e1f44d044a58fcd2caaca3f57e69cf6180db3dc Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657143957; 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=ujEtXG/eJZp4keKRIQWtaOjbOhAMagIw+TtCv1yrnaw=; b=dGwgYSTQthYZJD2eibPI+TGyl9hN/9el6tBJQOX+5b95PfYZ8fxVkj+dQB8DEanzosZ3Ta 6LYC689QiMhTagDHslAvpa4yrZp3RnEE/jGHgsKWrNlbVtwVAaenwvsHekIRMg1uXCL6jA ucLjwk3OdKSDLFH9cb+vOpgJQld6s8Tg/LWHrOgnS0QhnpSaaI5QCxm6ptB7xgj64EBf+Y BMpDy2fXVu1Wknv7Bs5yGj/T7eyE4RLsPUiB7ro/OhyD51AOxHbyTSkT9fUE3OfkjuWPs3 xW2rV+nwSEp1SM9KQMPBTwBCmWAfBADoWiFCWXvBOd5t+6ECml+R1zsibVsnQA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657143957; a=rsa-sha256; cv=none; b=hxgVNbOkCut80U6735t2uIr5Uw9i+ohBv3vIfSQnK6P3WS8rLdWhd9rlbhE1SzRaUqRjmT NZ5ArBNuuS2h+8MPeNImKXGC3COUx1ct15ZxTf/OqiNY8D9SQrxtWiJVyUwMNRMl++2rK7 OPac+5tGE3NyrmDDI71x/i3fEnaeaLIzt1KrQRrSrBtHmIa0i4FpqVC3XOsITnHqIa+qCW P6FiTcktZQS1s4QfH00mSpinvVmZ9Tn0scGxkWqQl1+PLR2p/NXwG4m32wXsOJqcYB8r2h J/T0DNp3+wMyobSLQ1umWJjSqj8+SJ+JfmOKY1Ksx/t7yHZh000r43YJoFYMJw== 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=9e1f44d044a58fcd2caaca3f57e69cf6180db3dc commit 9e1f44d044a58fcd2caaca3f57e69cf6180db3dc Author: Kirk McKusick AuthorDate: 2022-07-06 21:31:00 +0000 Commit: Kirk McKusick CommitDate: 2022-07-06 21:45:30 +0000 Bug fix to UFS/FFS superblock integrity checks when reading a superblock. The original check verified that if an alternate superblock has not been selected that the superblock is located in its standard location. 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 used for a UFS1 filesystems with a 65536 block size. This patch allows the use of the first backup superblock in that situation. Reported by: Peter Holm Tested by: Peter Holm MFC after: 1 month (with 076002f24d35) Differential Revision: https://reviews.freebsd.org/D35219 --- sys/ufs/ffs/ffs_subr.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/sys/ufs/ffs/ffs_subr.c b/sys/ufs/ffs/ffs_subr.c index 438745f8eb49..d87579832617 100644 --- a/sys/ufs/ffs/ffs_subr.c +++ b/sys/ufs/ffs/ffs_subr.c @@ -348,9 +348,21 @@ validate_sblock(struct fs *fs, int isaltsblk) %jd); } else if (fs->fs_magic == FS_UFS1_MAGIC) { if (!isaltsblk) { - CHK(fs->fs_sblockloc, >, SBLOCK_UFS1, %#jx); - CHK2(fs->fs_sblockactualloc, !=, SBLOCK_UFS1, - fs->fs_sblockactualloc, !=, 0, %jd); + 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_nindir, !=, fs->fs_bsize / sizeof(ufs1_daddr_t), %jd); @@ -382,7 +394,6 @@ validate_sblock(struct fs *fs, int isaltsblk) CHK(fs->fs_bsize, >, MAXBSIZE, %jd); CHK(fs->fs_bsize, <, roundup(sizeof(struct fs), DEV_BSIZE), %jd); CHK(fs->fs_sbsize, >, SBLOCKSIZE, %jd); - CHK(fs->fs_sbsize, <, fs->fs_fsize, %jd); CHK(powerof2(fs->fs_bsize), ==, 0, %jd); CHK(fs->fs_fsize, <, sectorsize, %jd); CHK(fs->fs_fsize, >, fs->fs_bsize, %jd);