Date: Fri, 13 Oct 2017 09:42:05 +0000 (UTC) From: Andriy Gapon <avg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r324591 - head/sys/kern Message-ID: <201710130942.v9D9g5oS014351@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: avg Date: Fri Oct 13 09:42:05 2017 New Revision: 324591 URL: https://svnweb.freebsd.org/changeset/base/324591 Log: remove process and jail directory machinations from dounmount The manipulations done by mountcheckdirs() are not that useful during the unmount, they can bring about unexpected security consequences. Thic change effectively reverts the change in r73241. The change also allows to simplify the handling of rootvnode global variable. Discussed with: mckusick, mjg, kib Reviewed by: trasz MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D12366 Modified: head/sys/kern/vfs_mount.c Modified: head/sys/kern/vfs_mount.c ============================================================================== --- head/sys/kern/vfs_mount.c Fri Oct 13 09:21:41 2017 (r324590) +++ head/sys/kern/vfs_mount.c Fri Oct 13 09:42:05 2017 (r324591) @@ -1262,7 +1262,7 @@ dounmount_cleanup(struct mount *mp, struct vnode *cove int dounmount(struct mount *mp, int flags, struct thread *td) { - struct vnode *coveredvp, *fsrootvp; + struct vnode *coveredvp; int error; uint64_t async_flag; int mnt_gen_r; @@ -1364,22 +1364,6 @@ dounmount(struct mount *mp, int flags, struct thread * MNT_IUNLOCK(mp); cache_purgevfs(mp, false); /* remove cache entries for this file sys */ vfs_deallocate_syncvnode(mp); - /* - * For forced unmounts, move process cdir/rdir refs on the fs root - * vnode to the covered vnode. For non-forced unmounts we want - * such references to cause an EBUSY error. - */ - if ((flags & MNT_FORCE) && - VFS_ROOT(mp, LK_EXCLUSIVE, &fsrootvp) == 0) { - if (mp->mnt_vnodecovered != NULL && - (mp->mnt_flag & MNT_IGNORE) == 0) - mountcheckdirs(fsrootvp, mp->mnt_vnodecovered); - if (fsrootvp == rootvnode) { - vrele(rootvnode); - rootvnode = NULL; - } - vput(fsrootvp); - } if ((mp->mnt_flag & MNT_RDONLY) != 0 || (flags & MNT_FORCE) != 0 || (error = VFS_SYNC(mp, MNT_WAIT)) == 0) error = VFS_UNMOUNT(mp, flags); @@ -1391,17 +1375,6 @@ dounmount(struct mount *mp, int flags, struct thread * * it doesn't exist anymore. */ if (error && error != ENXIO) { - if ((flags & MNT_FORCE) && - VFS_ROOT(mp, LK_EXCLUSIVE, &fsrootvp) == 0) { - if (mp->mnt_vnodecovered != NULL && - (mp->mnt_flag & MNT_IGNORE) == 0) - mountcheckdirs(mp->mnt_vnodecovered, fsrootvp); - if (rootvnode == NULL) { - rootvnode = fsrootvp; - vref(rootvnode); - } - vput(fsrootvp); - } MNT_ILOCK(mp); mp->mnt_kern_flag &= ~MNTK_NOINSMNTQ; if ((mp->mnt_flag & MNT_RDONLY) == 0) { @@ -1432,6 +1405,10 @@ dounmount(struct mount *mp, int flags, struct thread * VOP_UNLOCK(coveredvp, 0); } vfs_event_signal(NULL, VQ_UNMOUNT, 0); + if (rootvnode != NULL && mp == rootvnode->v_mount) { + vrele(rootvnode); + rootvnode = NULL; + } if (mp == rootdevmp) rootdevmp = NULL; vfs_mount_destroy(mp);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201710130942.v9D9g5oS014351>