From nobody Sun May 28 22:23:54 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 4QTtVM1cZQz4XySR; Sun, 28 May 2023 22:23:55 +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 4QTtVM14Z1z4JZL; Sun, 28 May 2023 22:23:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685312635; 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=Q7hWo+3WB3sfzjrBtkUbxBVPryj4UJy6cXfUI3vpdSY=; b=n7WDrfjj0J/g8UU6GBSMujqdq82VkQXa8gnm6dribqmpg0pL1OAd0s4VL9K2jCui9LMpHa Rym7sXIdNWI4h0ohLTbQRplHdGCYdAYAwFP7InHrZlGyd2lAqFv+osP14u2oURnf6zfrXt Ut9r5Yq1vcrZmxOeAk0WowcRauuLhdLwJDRGNZuamykFfF6jroJDQmms32bAd1WtdpgcjF qNUF0iMK8Cxkn4JFj5Llc/mApeMg6VolnEZQ6L6GetVo04bxB6S0kfI/P/HE2ACbDbJ92P AmyM3Ve5q3HHnwOggmT4j6vtiZrCPOlM7RHMea0TDOkQqD0XL7F4J/ejBcpwrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685312635; 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=Q7hWo+3WB3sfzjrBtkUbxBVPryj4UJy6cXfUI3vpdSY=; b=mXAcKpbIJruV/2rPyppyGCPYS3fMCOhtRcmNI4gLmoDTOcvFHXGhSDucm5S3aHEEU7a6rg 9eG5DOUciQhSM9Bez8ZDbQKsKvB/MNfCmcwwCs6MhCGC1nxy7jlTkn+Q1CrmpwI5HgIIld lrZsvQp+9ltF86+kB8PiqWPB++yGQedlyQuwdixyusNvBcdLq7b7e0MncgI0Ost+HjJMwO Li4LkQi1xMgaIyXyJX6A14/B+/iS7k45rovjVltSSUNncla2dYEkFkkGu2FbS5tlWOEGFh /yGDe3AOgSIDAnK8D4Yy5fDzNWHW8T1K8IzwU8bNj8Q4Q0t/ZibFfkiGcSNGPw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1685312635; a=rsa-sha256; cv=none; b=xDqUNgDHM3WP975TiQcmla60Bnc8i7oEmCXwuIYFVXW+Vkcb4pjHviYnX9gYfrekukhNRs e7bB63ay7ebFYa5zwSZuqlMkSuPsghJDfcG8G7nbR9uIk4Ih0flN5hiWBVMa707txnuMIq 4ZsinK6iLPvyEnUL0mLoFCtjpDhgnHpI++HJ/bfvrfXOjIpZFqPargEpUqd7mNW78V6tdj 8+6v41uTQnEz7qdc6g9Rmt3fvtKoATgqmSA/BdbFrXielHBjHHR4gGX2mmeUbMs+JMK62j L2zPO35yj7l1Wk1lperxZ5j80CMGZHSfWAJcUWsLlx/AC5fbeCSZTYwWuYNNBg== 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 4QTtVM07kgzn8W; Sun, 28 May 2023 22:23:55 +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 34SMNsAQ092562; Sun, 28 May 2023 22:23:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 34SMNs5P092561; Sun, 28 May 2023 22:23:54 GMT (envelope-from git) Date: Sun, 28 May 2023 22:23:54 GMT Message-Id: <202305282223.34SMNs5P092561@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: b796bfce4869 - 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: b796bfce48698449470b751de6b0d96ae7047202 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=b796bfce48698449470b751de6b0d96ae7047202 commit b796bfce48698449470b751de6b0d96ae7047202 Author: Kirk McKusick AuthorDate: 2023-05-28 22:23:16 +0000 Commit: Kirk McKusick CommitDate: 2023-05-28 22:23:37 +0000 Fix a bug in fsck_ffs(8) triggered by corrupted filesystems. Check for valid block numbers while loading journal entries that contain block numbers. If an invalid block number is found, fall back to full fsck. Reported-by: Robert Morris PR: 271383 MFC-after: 1 week Sponsored-by: The FreeBSD Foundation --- sbin/fsck_ffs/suj.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sbin/fsck_ffs/suj.c b/sbin/fsck_ffs/suj.c index d51e0ff4d83b..c86d6b711635 100644 --- a/sbin/fsck_ffs/suj.c +++ b/sbin/fsck_ffs/suj.c @@ -736,7 +736,7 @@ indir_visit(ino_t ino, ufs_lbn_t lbn, ufs2_daddr_t blk, uint64_t *frags, lbnadd *= NINDIR(fs); bp = getdatablk(blk, fs->fs_bsize, BT_LEVEL1 + level); if (bp->b_errs != 0) - err_suj("indir_visit: UNRECOVERABLE I/O ERROR"); + err_suj("indir_visit: UNRECOVERABLE I/O ERROR\n"); for (i = 0; i < NINDIR(fs); i++) { if ((nblk = IBLK(bp, i)) == 0) continue; @@ -1918,6 +1918,9 @@ blk_build(struct jblkrec *blkrec) blk = blknum(fs, blkrec->jb_blkno); frag = fragnum(fs, blkrec->jb_blkno); + if (blkrec->jb_blkno < 0 || blk + fs->fs_frag - frag > fs->fs_size) + err_suj("Out-of-bounds journal block number %jd\n", + blkrec->jb_blkno); sblk = blk_lookup(blk, 1); /* * Rewrite the record using oldfrags to indicate the offset into