diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 917d4e27a20d..b4b37a0bf50b 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -576,7 +576,9 @@ vfs_donmount(struct thread *td, int fsflags, struct uio *fsoptions) goto bail; } + mtx_lock(&Giant); error = vfs_domount(td, fstype, fspath, fsflags, optlist, 0); + mtx_unlock(&Giant); bail: if (error) vfs_freeopts(optlist); @@ -619,9 +621,12 @@ mount(td, uap) error = copyinstr(uap->type, fstype, MFSNAMELEN, NULL); if (error == 0) error = copyinstr(uap->path, fspath, MNAMELEN, NULL); - if (error == 0) + if (error == 0) { + mtx_lock(&Giant); error = vfs_domount(td, fstype, fspath, uap->flags, uap->data, 1); + mtx_unlock(&Giant); + } free(fstype, M_TEMP); free(fspath, M_TEMP); return (error); @@ -643,8 +648,12 @@ vfs_mount(td, fstype, fspath, fsflags, fsdata) int fsflags; void *fsdata; { + int error; - return (vfs_domount(td, fstype, fspath, fsflags, fsdata, 1)); + mtx_lock(&Giant); + error = vfs_domount(td, fstype, fspath, fsflags, fsdata, 1); + mtx_unlock(&Giant); + return (error); } /* @@ -668,6 +677,8 @@ vfs_domount( struct vattr va; struct nameidata nd; + mtx_assert(&Giant, MA_OWNED); + /* * Be ultra-paranoid about making sure the type and fspath * variables will fit in our mp buffers, including the @@ -1067,7 +1078,10 @@ unmount(td, uap) */ if (mp->mnt_flag & MNT_ROOTFS) return (EINVAL); - return (dounmount(mp, uap->flags, td)); + mtx_lock(&Giant); + error = dounmount(mp, uap->flags, td); + mtx_unlock(&Giant); + return (error); } /* @@ -1083,6 +1097,8 @@ dounmount(mp, flags, td) int error; int async_flag; + mtx_assert(&Giant, MA_OWNED); + mtx_lock(&mountlist_mtx); if (mp->mnt_kern_flag & MNTK_UNMOUNT) { mtx_unlock(&mountlist_mtx); @@ -1568,6 +1584,7 @@ __mnt_vnode_next(struct vnode **nvp, struct mount *mp) struct vnode *vp; mtx_assert(&mp->mnt_mtx, MA_OWNED); + vp = *nvp; /* Check if we are done */ if (vp == NULL)