From nobody Sat Jan 08 04:29:29 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 5F7C81931F7B; Sat, 8 Jan 2022 04:29:30 +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 4JW6Yk06yyz3Dkp; Sat, 8 Jan 2022 04:29:30 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 CD96C18454; Sat, 8 Jan 2022 04:29:29 +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 2084TTNE022194; Sat, 8 Jan 2022 04:29:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2084TT7B022193; Sat, 8 Jan 2022 04:29:29 GMT (envelope-from git) Date: Sat, 8 Jan 2022 04:29:29 GMT Message-Id: <202201080429.2084TT7B022193@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 595ed4d76713 - main - msdosfs: handle inconsistently hashed denodes 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 595ed4d76713c1e9cab7d8a160ed59f8f4e5ecb4 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641616170; 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=8yCSeLrTBUEKbrUZMWkMOmKMfVAT3SSi+Xgo84Rxp0o=; b=xBpzdpefodSZNZly9iLGhv78iFBZHq9bbjMP4AlGrrOemk68rOHpFsTbthzFjg449YZbrx iEm7Gl2Bb6ZEVZbFhJ/v/7M8zBgTgFXv0y8aBxKYJBdkmalz4dZgI+SSTOdeDb6Y0FL82e c9VIZzhJjmHtziYGinQlQGifWvr+57Hfoh5K5geF1km9gPcrUUNpahKLBG9gOniZ1G/xu9 RiaTifDDoylBohA0QGmH0TyYabtsMfgwa8ffd+KtMpc8XN6b8RDkCHI+gZynWuTgcIZGlS 6D2G4kbJCmcp5x9Xrk1QftTjx0WUwc9cbezghkuHrT+l9Fmk6AXIPE8TwMfJZw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641616170; a=rsa-sha256; cv=none; b=KcvP24+8twfG1Wxitnpx4zWLQTRkgaAZDPfN6gvFxdDjLfgff/KUt5310H21C1TwXsl2ru ltPU3okSKSN4b41tDEYOsAF8EmqSd+7tBmqreH7QgWtzCQG76OjqN5ad6nuV3Q6ZlDggMX 0/huRCS5NSVgeUxOlf4sW5ce56wo6M9VxYffOXEuY2z3Ngb+0c8VXn57+H+tunbLzwddRk S4O9I6qkJDA3Ca70KDdNK2elnlK3JJzg0If5ReT5t8G5Uoq6Cl/NYTox3PsfifWVFQPJo3 3Y3jIMzJhozo6FB+JuwdRhlbhfQugg7/NKmz6mdXBs0iMEWT+b9f0en1nBvUMw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=595ed4d76713c1e9cab7d8a160ed59f8f4e5ecb4 commit 595ed4d76713c1e9cab7d8a160ed59f8f4e5ecb4 Author: Konstantin Belousov AuthorDate: 2021-12-23 23:21:53 +0000 Commit: Konstantin Belousov CommitDate: 2022-01-08 03:41:44 +0000 msdosfs: handle inconsistently hashed denodes It is possible, on the corrupted msdosfs volume, to have file which denode inode number does not match the one calculated using directory cluster. Instead of asserting the condition as impossible, handle it and return error, after reclaiming the aliased vnode. In collaboration with: pho Reviewed by: markj, mckusick Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D33721 --- sys/fs/msdosfs/msdosfs_denode.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/sys/fs/msdosfs/msdosfs_denode.c b/sys/fs/msdosfs/msdosfs_denode.c index 64f75c267959..8ca9fa38b1cf 100644 --- a/sys/fs/msdosfs/msdosfs_denode.c +++ b/sys/fs/msdosfs/msdosfs_denode.c @@ -142,9 +142,23 @@ deget(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset, return (error); if (nvp != NULL) { *depp = VTODE(nvp); - KASSERT((*depp)->de_dirclust == dirclust, ("wrong dirclust")); - KASSERT((*depp)->de_diroffset == diroffset, ("wrong diroffset")); + if ((*depp)->de_dirclust != dirclust) { + printf("%s: wrong dir cluster %lu %lu\n", + pmp->pm_mountp->mnt_stat.f_mntonname, + (*depp)->de_dirclust, dirclust); + goto badoff; + } + if ((*depp)->de_diroffset != diroffset) { + printf("%s: wrong dir offset %lu %lu\n", + pmp->pm_mountp->mnt_stat.f_mntonname, + (*depp)->de_diroffset, diroffset); + goto badoff; + } return (0); +badoff: + vgone(nvp); + vput(nvp); + return (EBADF); } ldep = malloc(sizeof(struct denode), M_MSDOSFSNODE, M_WAITOK | M_ZERO);