git: 41e85eeab90d - main - msdosfs: on integrity error, fire a task to remount filesystem to ro
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 08 Jan 2022 04:29:38 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=41e85eeab90dec540c7aa3973ba601bae1f16c10 commit 41e85eeab90dec540c7aa3973ba601bae1f16c10 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2021-12-25 19:45:47 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> 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 "." */