From nobody Mon May 29 21:59:00 2023 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 4QVTv906Vpz4XDg0; Mon, 29 May 2023 21:59:01 +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 4QVTv86nXqz3G6G; Mon, 29 May 2023 21:59:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685397541; 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=AFoVXlMWEieuZyDGd8rNwAbTxpbDPsSV1uKpQtyUduI=; b=fR5vBmiQZsS92WCGoxGZE4EcqIXWL0zcvM8q5UYIQFexQ/tTwMUnuMFhyLfEKpMEYNyUGn KU+BtVqa5PNJSzXi51u44RZaiaVWx7zeu/RhHxuh4z1lx+UBFHJoT8Z4/NvyX0jVjeMOO6 fz59IEpCY77kUKDsC7r+f03jREyfUcwv5gwyKu4ZADccZ3mA5M/evxcpbIqe+zmJnL9rX7 YITHukLAoaDsHl8DHeQgKIBZxlODOv8cXl8wrFUU8CNWg+uq73qJ0kYpuFL16fUQe2sE4J /gsTWzj35Ljm57Luo1aQ1EgdH2bf6LH/TaSJtNbjr3rHZJ5U3M7OtAbGmUhk9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685397540; 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=AFoVXlMWEieuZyDGd8rNwAbTxpbDPsSV1uKpQtyUduI=; b=L157R2bYUqgVhmvDDhv+NmORXtzJPimKogIAnj9imKh2vw9ecZOixsiKfGjxxd0ZGn0M2H LpvfYWqqvkM7sshVlnOORBmN8SOmEocZDf0wSFEdrqnalWjKbrpZrGZaNUmDysSa0u16dH 3fClkyQKRQBqOclfvLj4e7LSvPrayBqizO6RtHIpQ1nrlZnYgTxKXU9ln56onwensgfmYo QxklVtDS5kS0G2xs0CutfJGde4T+ohcKBdnED8uH8Mur1YEfgN8oR4gLgACYv2jQd3G5kG bSdPxGp8PPDW5zNJgSbRbWOSEPTkP0VKiILXe5qsnsFhnmVwFfLaQZOcRmSnbA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1685397540; a=rsa-sha256; cv=none; b=cnQELKEL2pusB3M/Qycpdl00B2Dwju/A2aOvvBVCOMohaUkh5/l+N+cJeRfd+XtQ4Oxl7O JvnPgwEoO2OHzvRZ9SPRXDPgr1MrykoRJUfxW810tXtrkokdd9zOsLPOVP1i71MdNgHeAY CAhccueUl0h68m91dd6W/nrzBWB4rdMNxw21pJgZGyznA1gNZJX2SKjWZcx/KkrxHBk0C/ FFtCmlAwWQ57/xl8z6ge0bWOmoTdbkkBZePPF1271KJGUJALvOdu3A+0zv1DVKVjzfS3Y0 QkhJquhXgzkTCCnoWI74bNoHNOqwTq9jTu0GeU+Aq40lPhmP3maVL7EORSWxQQ== 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 4QVTv85pQPzSqg; Mon, 29 May 2023 21:59:00 +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 34TLx0vf015789; Mon, 29 May 2023 21:59:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 34TLx0g0015788; Mon, 29 May 2023 21:59:00 GMT (envelope-from git) Date: Mon, 29 May 2023 21:59:00 GMT Message-Id: <202305292159.34TLx0g0015788@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: 6a71277c3037 - main - Fix a bug in fsck_ffs(8) triggered by corrupted filesystems. 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: 6a71277c3037df2c3a70464c2e2bf20dec2c128a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=6a71277c3037df2c3a70464c2e2bf20dec2c128a commit 6a71277c3037df2c3a70464c2e2bf20dec2c128a Author: Kirk McKusick AuthorDate: 2023-05-29 21:58:20 +0000 Commit: Kirk McKusick CommitDate: 2023-05-29 21:58:20 +0000 Fix a bug in fsck_ffs(8) triggered by corrupted filesystems. When loading the root directory ensure that it is a directory and has a size greater than the minimum directory size. If an invalid root directory is found, fall back to full fsck. Reported-by: Robert Morris PR: 271414 MFC-after: 1 week Sponsored-by: The FreeBSD Foundation --- sbin/fsck_ffs/suj.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sbin/fsck_ffs/suj.c b/sbin/fsck_ffs/suj.c index c86d6b711635..1e935b864b7c 100644 --- a/sbin/fsck_ffs/suj.c +++ b/sbin/fsck_ffs/suj.c @@ -2377,7 +2377,7 @@ suj_check(const char *filesys) { struct inodesc idesc; struct csum *cgsum; - union dinode *jip; + union dinode *dp, *jip; struct inode ip; uint64_t blocks; int i, retval; @@ -2419,7 +2419,17 @@ suj_check(const char *filesys) idesc.id_func = findino; idesc.id_name = SUJ_FILE; ginode(UFS_ROOTINO, &ip); - if ((ckinode(ip.i_dp, &idesc) & FOUND) == FOUND) { + dp = ip.i_dp; + if ((DIP(dp, di_mode) & IFMT) != IFDIR) { + irelse(&ip); + err_suj("root inode is not a directory\n"); + } + if (DIP(dp, di_size) < 0 || DIP(dp, di_size) > MAXDIRSIZE) { + irelse(&ip); + err_suj("negative or oversized root directory %jd\n", + (uintmax_t)DIP(dp, di_size)); + } + if ((ckinode(dp, &idesc) & FOUND) == FOUND) { sujino = idesc.id_parent; irelse(&ip); } else {