diff options
author | tegge <tegge@FreeBSD.org> | 2006-09-26 04:12:49 +0000 |
---|---|---|
committer | tegge <tegge@FreeBSD.org> | 2006-09-26 04:12:49 +0000 |
commit | 83154f853d9ca39deb1add01e032aff1f0678514 (patch) | |
tree | ac46e0b5a80f88127d3d14dc940a5f2746573c00 /sys/kern/vfs_export.c | |
parent | d7fe3e736512a1dd37a985037184eecf7df1f26d (diff) | |
download | FreeBSD-src-83154f853d9ca39deb1add01e032aff1f0678514.zip FreeBSD-src-83154f853d9ca39deb1add01e032aff1f0678514.tar.gz |
Use mount interlock to protect all changes to mnt_flag and mnt_kern_flag.
This eliminates a race where MNT_UPDATE flag could be lost when nmount()
raced against sync(), sync_fsync() or quotactl().
Diffstat (limited to 'sys/kern/vfs_export.c')
-rw-r--r-- | sys/kern/vfs_export.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sys/kern/vfs_export.c b/sys/kern/vfs_export.c index 5552845..00237b6 100644 --- a/sys/kern/vfs_export.c +++ b/sys/kern/vfs_export.c @@ -117,7 +117,9 @@ vfs_hang_addrlist(mp, nep, argp) bcopy(argp->ex_anon.cr_groups, np->netc_anon.cr_groups, sizeof(np->netc_anon.cr_groups)); refcount_init(&np->netc_anon.cr_ref, 1); + MNT_ILOCK(mp); mp->mnt_flag |= MNT_DEFEXPORTED; + MNT_IUNLOCK(mp); return (0); } @@ -236,13 +238,17 @@ vfs_export(mp, argp) return (ENOENT); if (mp->mnt_flag & MNT_EXPUBLIC) { vfs_setpublicfs(NULL, NULL, NULL); + MNT_ILOCK(mp); mp->mnt_flag &= ~MNT_EXPUBLIC; + MNT_IUNLOCK(mp); } vfs_free_addrlist(nep); mp->mnt_export = NULL; free(nep, M_MOUNT); nep = NULL; + MNT_ILOCK(mp); mp->mnt_flag &= ~(MNT_EXPORTED | MNT_DEFEXPORTED); + MNT_IUNLOCK(mp); } if (argp->ex_flags & MNT_EXPORTED) { if (nep == NULL) { @@ -252,11 +258,15 @@ vfs_export(mp, argp) if (argp->ex_flags & MNT_EXPUBLIC) { if ((error = vfs_setpublicfs(mp, nep, argp)) != 0) return (error); + MNT_ILOCK(mp); mp->mnt_flag |= MNT_EXPUBLIC; + MNT_IUNLOCK(mp); } if ((error = vfs_hang_addrlist(mp, nep, argp))) return (error); + MNT_ILOCK(mp); mp->mnt_flag |= MNT_EXPORTED; + MNT_IUNLOCK(mp); } return (0); } |