From nobody Sat Mar 18 22:38:24 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 4PfG9r6VQhz406Hd; Sat, 18 Mar 2023 22:38:24 +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 4PfG9r53gFz44n1; Sat, 18 Mar 2023 22:38:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679179104; 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=zMTaX/uKYS82Pl/5D+MwAypchN37u8/AMQOEiGpZ4n8=; b=DxJ3ItPtLrkYlzvsdHlol/JzPXVKVi9kuAcRGa2W+o18QAbayrC/ux2Sq9Evcw/RFEstWN CnRwSEISOPqw5AE1yTKEp8aMxk7uuHpsNdVlXCtszxOeIzNH5S3V6UoTj8bzYA+1hfegL6 eLTQrNg5l/TXXGUz84jS90IW0Q3C7YAjKkjN12Hg0nW5aVMwaestAxExLMjwRBwfRnJ+fJ Lg5KcxGwY7Cadb3I+FQpmmK2CjyZDNibn+L4toQY+fEzDxNkrLU4g2/3sAlS683S+3jrj9 MtIdj0PUsgozqqIWNr6qcVuEItbAarGaDLN6u6naCGG114tDXW8BDqG8lHIT9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679179104; 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=zMTaX/uKYS82Pl/5D+MwAypchN37u8/AMQOEiGpZ4n8=; b=aS+84Wny92I4B/rMpZAXxwBNSRUwj59vIRk1FsKuJd0S3TZ10QyoaCsqWm5YqWrNhrusK4 zbyRoAlFIMWeizxWCQrLruTMfmP+JqMVZycSIo+RZbwvZeO85ZXzKoPZ9Iga++NwZg0pid lR04/x1ONv8CL6lJ4eodz5Pelio7sq8scqFzuARjJJws2Sm4erICQBOuUzR6zKhh+RZryw J9eiUtVwP4/w+G/Z6pc62Hw6TV6IsQHd5+45FJhhJBtOIZDP5QiutebjHB/aKd3Vrh+vxQ KfArDxqIXX5ZrqFlTLCee7vN/Z/ithejmqbePqwlQDVgCwN0eVtIwzJVObHslA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1679179104; a=rsa-sha256; cv=none; b=Onb3TOqAaDQBL6CPEw6OHMagCbKV/r1V5lqVRG2dX7QrqOvbAGzGd67+232UPs0Srox1hy Ncb5dd/0nwkiuTfCQJtzxrcbgYEvCRqXgYOII50Q8UYFprXhAgNOfl6D9VjGMPy6f3j0eb molA6ubLY8t1U2Xce1rJ5uq/8tEXi+MndlFJ7dOD9uLiUUjMT2Iz7Fl4HtgUDw69axtuSV 5pSrMQjimfQpBDXVLEYXeYiKD8xBxgAxbBw9WEpngD7FLggic7AaVqF6zFMeFjts3VlVI2 KUvXpiScYOVcggaBK9y706nNfP8TfJDSMg2v2ii/EgnLP2tNfxE3wDaYXOyQyg== 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 4PfG9r45X2zQB1; Sat, 18 Mar 2023 22:38:24 +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 32IMcOlL032845; Sat, 18 Mar 2023 22:38:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32IMcOAb032844; Sat, 18 Mar 2023 22:38:24 GMT (envelope-from git) Date: Sat, 18 Mar 2023 22:38:24 GMT Message-Id: <202303182238.32IMcOAb032844@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: 069767091e54 - main - Do not panic in case of corrupted UFS/FFS directory. 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: 069767091e54a2537ae509dcdf3005fb0f50ab84 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=069767091e54a2537ae509dcdf3005fb0f50ab84 commit 069767091e54a2537ae509dcdf3005fb0f50ab84 Author: Kirk McKusick AuthorDate: 2023-03-18 22:36:54 +0000 Commit: Kirk McKusick CommitDate: 2023-03-18 22:37:58 +0000 Do not panic in case of corrupted UFS/FFS directory. Historically the system panic'ed when it encountered a corrupt directory. This change recovers well enough to continue operations. This change is made in response to a similar change made in the ext2 filesystem as described in the cited Differential Revision. MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D38503 --- sys/ufs/ufs/ufs_lookup.c | 18 +++++------------- sys/ufs/ufs/ufs_vnops.c | 4 +++- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c index 4c390f4c42ef..cabd04a50bfd 100644 --- a/sys/ufs/ufs/ufs_lookup.c +++ b/sys/ufs/ufs/ufs_lookup.c @@ -548,9 +548,8 @@ found: */ if (i_offset + DIRSIZ(OFSFMT(vdp), ep) > dp->i_size) { ufs_dirbad(dp, i_offset, "i_size too small"); - dp->i_size = i_offset + DIRSIZ(OFSFMT(vdp), ep); - DIP_SET(dp, i_size, dp->i_size); - UFS_INODE_SET_FLAG(dp, IN_SIZEMOD | IN_CHANGE | IN_UPDATE); + brelse(bp); + return (EIO); } brelse(bp); @@ -758,17 +757,10 @@ found: void ufs_dirbad(struct inode *ip, doff_t offset, char *how) { - struct mount *mp; - mp = ITOV(ip)->v_mount; - if ((mp->mnt_flag & MNT_RDONLY) == 0) - panic("ufs_dirbad: %s: bad dir ino %ju at offset %ld: %s", - mp->mnt_stat.f_mntonname, (uintmax_t)ip->i_number, - (long)offset, how); - else - (void)printf("%s: bad dir ino %ju at offset %ld: %s\n", - mp->mnt_stat.f_mntonname, (uintmax_t)ip->i_number, - (long)offset, how); + (void)printf("%s: bad dir ino %ju at offset %ld: %s\n", + ITOV(ip)->v_mount->mnt_stat.f_mntonname, (uintmax_t)ip->i_number, + (long)offset, how); } /* diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index ae6d963920f3..54046c285fd7 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -1730,7 +1730,9 @@ relock: /* Journal must account for each new link. */ softdep_setup_dotdot_link(tdp, fip); SET_I_OFFSET(fip, mastertemplate.dot_reclen); - ufs_dirrewrite(fip, fdp, newparent, DT_DIR, 0); + if (ufs_dirrewrite(fip, fdp, newparent, DT_DIR, 0) != 0) + ufs_dirbad(fip, mastertemplate.dot_reclen, + "rename: missing ".." entry"); cache_purge(fdvp); } error = ufs_dirremove(fdvp, fip, fcnp->cn_flags, 0);