From nobody Sat Jan 08 04:29:38 2022 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 AB64A19322B3; Sat, 8 Jan 2022 04:29:41 +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 4JW6Yv4Lxgz3DlY; Sat, 8 Jan 2022 04:29:39 +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 DCDD91857C; Sat, 8 Jan 2022 04:29:38 +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 2084Tc5j022393; Sat, 8 Jan 2022 04:29:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2084Tctx022392; Sat, 8 Jan 2022 04:29:38 GMT (envelope-from git) Date: Sat, 8 Jan 2022 04:29:38 GMT Message-Id: <202201080429.2084Tctx022392@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: 41e85eeab90d - main - msdosfs: on integrity error, fire a task to remount filesystem to ro 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 41e85eeab90dec540c7aa3973ba601bae1f16c10 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641616180; 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=FXAiYJWtTLp9oE92MQbpOEv9EsFnplAQaQBCwf5s9V0=; b=iWOD6I2EJrSV+Ta3kv3YHh8bseomBQseoqePp1sZq9NBeR2eEAnIsBOxFdgey+9b68q5K9 6mgtYl/xRwz3Rhswrd+gRxgHxR5HP+XMm8MP90elEbZLLYxsju8olpBJ97YJuw3qAQWeWu YXjckuCGGQRrVyMHfZ0QnSK3JXdxraDa9mh77SO4ttVqkt0Bpeg3FMDLFsFLwCIFoH6sOM vxf4bOjwfm34QAk3IeWYDynaWc0VUvbsX3ICqOmsx0djDRZrmQP3Nwu/zVH+27dq0WN+5J BsSujvhisqVldG0axnE+J/piakjhQAbY6zqUrasQ8nUhQyPcWyxxQJO0h5NGeQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641616180; a=rsa-sha256; cv=none; b=Assx5YpEW3hy3v8lmLqqucyom+eNPT+x8rjp89OObQoTEZqRtYZjjBq5nr9cSK/Zd2ypnB UvTDGSjy3mJEM3mhKLij8HctJoEzCzLqHE5Dqsh55kuVcQjnmfViDANTD3h8xUQdYkE7/L vcSsfkaH5NVbI9RdLTFn5lXkSI2Yj3/P22ijoIsbAZrpam8aRCcPnjM10/F5dv3j1rDtej F2eEbRAxpi0ttG74WRQhwSNfWjhXFIEwAnb4ulw+G9+zHE5FThX30K9esBbT8lwgcaA3Me xtyCGqdMlsaqWIr4RhVdxH4kJdT2ASTcSk2pnbgGOeTDq0ojy05zqbFvp+tUKw== 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=41e85eeab90dec540c7aa3973ba601bae1f16c10 commit 41e85eeab90dec540c7aa3973ba601bae1f16c10 Author: Konstantin Belousov AuthorDate: 2021-12-25 19:45:47 +0000 Commit: Konstantin Belousov CommitDate: 2022-01-08 04:20:48 +0000 msdosfs: on integrity error, fire a task to remount filesystem to ro 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 | 1 + sys/fs/msdosfs/msdosfs_fat.c | 1 + sys/fs/msdosfs/msdosfs_lookup.c | 6 +++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/sys/fs/msdosfs/msdosfs_denode.c b/sys/fs/msdosfs/msdosfs_denode.c index 8ca9fa38b1cf..2d682fa403dc 100644 --- a/sys/fs/msdosfs/msdosfs_denode.c +++ b/sys/fs/msdosfs/msdosfs_denode.c @@ -158,6 +158,7 @@ deget(struct msdosfsmount *pmp, u_long dirclust, u_long diroffset, badoff: vgone(nvp); vput(nvp); + msdosfs_integrity_error(pmp); return (EBADF); } ldep = malloc(sizeof(struct denode), M_MSDOSFSNODE, M_WAITOK | M_ZERO); diff --git a/sys/fs/msdosfs/msdosfs_fat.c b/sys/fs/msdosfs/msdosfs_fat.c index fc1db705989b..e6d9b671e7d7 100644 --- a/sys/fs/msdosfs/msdosfs_fat.c +++ b/sys/fs/msdosfs/msdosfs_fat.c @@ -412,6 +412,7 @@ usemap_free(struct msdosfsmount *pmp, u_long cn) printf("%s: Freeing unused sector %ld %ld %x\n", pmp->pm_mountp->mnt_stat.f_mntonname, cn, cn % N_INUSEBITS, (unsigned)pmp->pm_inusemap[cn / N_INUSEBITS]); + msdosfs_integrity_error(pmp); return (EINTEGRITY); } pmp->pm_freeclustercount++; diff --git a/sys/fs/msdosfs/msdosfs_lookup.c b/sys/fs/msdosfs/msdosfs_lookup.c index 3db9665f6094..91b778b8173b 100644 --- a/sys/fs/msdosfs/msdosfs_lookup.c +++ b/sys/fs/msdosfs/msdosfs_lookup.c @@ -77,6 +77,7 @@ msdosfs_lookup_checker(struct msdosfsmount *pmp, struct vnode *dvp, */ if (vp == dvp) { vput(vp); + msdosfs_integrity_error(pmp); *vpp = NULL; return (EBADF); } @@ -595,10 +596,13 @@ foundroot: vput(*vpp); goto restart; } - return (msdosfs_lookup_checker(pmp, vdp, VTODE(*vpp), vpp)); + error = msdosfs_lookup_checker(pmp, vdp, VTODE(*vpp), vpp); + if (error != 0) + return (error); } else if (dp->de_StartCluster == scn && isadir) { if (cnp->cn_namelen != 1 || cnp->cn_nameptr[0] != '.') { /* fs is corrupted, non-dot lookup returned dvp */ + msdosfs_integrity_error(pmp); return (EBADF); } VREF(vdp); /* we want ourself, ie "." */