From nobody Sat Aug 13 20:28:57 2022 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 4M4sZd4956z4Z2Wr; Sat, 13 Aug 2022 20:28:57 +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 4M4sZd3Lw0z43g6; Sat, 13 Aug 2022 20:28:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660422537; 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=cLV7M7sRBqoGm313xDgXUkL69miUZOp5UJWNPWh+n6Y=; b=x0oT4DrjGWmf8ccLJgNWxECUXTvS3co6kzgx84lZsf9U/XLs2cVI+qRLt7tf/AHzHfIl9i Uz/+YBcvFKut2Fl7DIdiPh7D9LhELqk0wVwYY7tZjtxqzJm+giyHiFC0NUIegXiHCBdnv5 xcHqGReqnHmVDi4yKm4jsNgGRE3foHjCRLroJYCF4DruvaFKHhxg/JQVqk6kyzSYWvyrTr sRnUOwpxfDdyJBr6Tz88k1ayM8n4futbFwTb00uxjm5tJsrajyXBQx9DRqYhT70cx8/AQ2 7DMVB5d1zKUPrt97FcODRhIUVjZH4146WjCKv5asCdY+NitdIXv1GwiwQI76AQ== 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 4M4sZd2HMXzPYB; Sat, 13 Aug 2022 20:28: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 27DKSv1f000805; Sat, 13 Aug 2022 20:28:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27DKSvg4000804; Sat, 13 Aug 2022 20:28:57 GMT (envelope-from git) Date: Sat, 13 Aug 2022 20:28:57 GMT Message-Id: <202208132028.27DKSvg4000804@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: 6e821c35d68d - main - Correctness cleanups in fsck_ffs(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: 6e821c35d68d4041640b27419837464ffab65cff Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660422537; 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=cLV7M7sRBqoGm313xDgXUkL69miUZOp5UJWNPWh+n6Y=; b=G5IrihWojlK/uS9jkVPIb66W233Sa/NZ4c4tqNH1DPilmuOpcABJqtpZfeFx/TBrb2GsF6 myk7oyTjsWnHArdhSDatNd/G4qSoY0wPY218/KxQ9IC67z9YijnYF9XoHn+rKJmcaWwiXO T6YuL9RJnjgvSF0Ir/uGMy+QvhJbzpKvMpGe8azPhzrPjwFNr7LsUSnyKtnV1T6yEfc/D0 DUKBKkSIuV+RkcyMjj7zdMkOC5P9sbZYGdgX5z0sdoTDNhSqyMJl4WX6lfLqRx5zGQeaxZ kvgFJIAPCYhirq7vuuvi7iwoCNlSJU16qyZOJ7xt1sc7a6Gyuw2Va6oJysFNrQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1660422537; a=rsa-sha256; cv=none; b=RvxouiXtw0CFLacoR0kciBmMGyD11lymD8f8fhNsYf5/e+222+1MImnSaWcbwB01lc7OhJ xu8zDjEZcuJD41raW2SeWWY75qp2kOqe7JxSaENkt1GnWdk2REAf2WJ8AZNF9o/XEzGMb4 xeAoGUx2wiFdvoEM7ct5007wEed4DdpfbKfQyqfGBUxhg7etcZdeb14uHV8hAkQkjRDGYd lqV4/N5sStLUfJX7yqP2mTBnJfGDTbnTZYq3O2glWoloCtn8Yvm69lqobW97ABaC48f62F 4DrS7xKboj7nqSzAvPWDAjWAIt+G5od/Qh/rp2uBvuTnb6e1gEA1KNWSjS8VSQ== 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=6e821c35d68d4041640b27419837464ffab65cff commit 6e821c35d68d4041640b27419837464ffab65cff Author: Kirk McKusick AuthorDate: 2022-08-13 20:27:37 +0000 Commit: Kirk McKusick CommitDate: 2022-08-13 20:28:31 +0000 Correctness cleanups in fsck_ffs(8). Allocation or I/O failures in fsck_ffs(8) could cause segment faults because of missing checks or not-yet-initialized data structures. Correct these issues. Reported by: Peter Holm Sponsored by: The FreeBSD Foundation --- sbin/fsck_ffs/inode.c | 3 +++ sbin/fsck_ffs/setup.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c index 47f72c84a1f2..8a93ad092a4a 100644 --- a/sbin/fsck_ffs/inode.c +++ b/sbin/fsck_ffs/inode.c @@ -474,6 +474,9 @@ void irelse(struct inode *ip) { + /* Check for failed inode read */ + if (ip->i_bp == NULL) + return; if (ip->i_bp->b_refcnt <= 0) pfatal("irelse: releasing unreferenced ino %ju\n", (uintmax_t) ip->i_number); diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c index 022799117eb0..3db59e611729 100644 --- a/sbin/fsck_ffs/setup.c +++ b/sbin/fsck_ffs/setup.c @@ -145,6 +145,7 @@ setup(char *dev) /* * allocate and initialize the necessary maps */ + bufinit(); bmapsize = roundup(howmany(maxfsblock, CHAR_BIT), sizeof(short)); blockmap = Calloc((unsigned)bmapsize, sizeof (char)); if (blockmap == NULL) { @@ -169,7 +170,6 @@ setup(char *dev) (uintmax_t)numdirs * sizeof(struct inoinfo *)); goto badsb; } - bufinit(); if (sblock.fs_flags & FS_DOSOFTDEP) usedsoftdep = 1; else