Correct several instances where calls to vfs_getvfs() resulting in
failure in the NFS server would result in a leaked instance of the NFS server subsystem lock. Liberally sprinkle assertions in all target labels for error unwinding to assert the desired locking state. RELENG_5_3 candidate. MFC after: 3 days Reported by: Wilkinson, Alex <alex dot wilkinson at dsto dot defence dot gov dot au>
This commit is contained in:
parent
082a6f6612
commit
ae8c2fa228
@ -225,6 +225,7 @@ nfsrv3_access(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
|||||||
tl = nfsm_build(u_int32_t *, NFSX_UNSIGNED);
|
tl = nfsm_build(u_int32_t *, NFSX_UNSIGNED);
|
||||||
*tl = txdr_unsigned(nfsmode);
|
*tl = txdr_unsigned(nfsmode);
|
||||||
nfsmout:
|
nfsmout:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
if (vp) {
|
if (vp) {
|
||||||
NFSD_UNLOCK();
|
NFSD_UNLOCK();
|
||||||
mtx_lock(&Giant); /* VFS */
|
mtx_lock(&Giant); /* VFS */
|
||||||
@ -285,6 +286,7 @@ nfsrv_getattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
|||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
||||||
nfsmout:
|
nfsmout:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
if (vp) {
|
if (vp) {
|
||||||
NFSD_UNLOCK();
|
NFSD_UNLOCK();
|
||||||
mtx_lock(&Giant); /* VFS */
|
mtx_lock(&Giant); /* VFS */
|
||||||
@ -412,6 +414,7 @@ nfsrv_setattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
|||||||
mtx_unlock(&Giant); /* VFS */
|
mtx_unlock(&Giant); /* VFS */
|
||||||
NFSD_LOCK();
|
NFSD_LOCK();
|
||||||
}
|
}
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the size is being changed write acces is required, otherwise
|
* If the size is being changed write acces is required, otherwise
|
||||||
@ -439,6 +442,7 @@ nfsrv_setattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
|||||||
if (!error)
|
if (!error)
|
||||||
error = postat_ret;
|
error = postat_ret;
|
||||||
out:
|
out:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
if (vp != NULL) {
|
if (vp != NULL) {
|
||||||
NFSD_UNLOCK();
|
NFSD_UNLOCK();
|
||||||
mtx_lock(&Giant); /* VFS */
|
mtx_lock(&Giant); /* VFS */
|
||||||
@ -460,6 +464,7 @@ out:
|
|||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
||||||
nfsmout:
|
nfsmout:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
NFSD_UNLOCK();
|
NFSD_UNLOCK();
|
||||||
mtx_lock(&Giant); /* VFS */
|
mtx_lock(&Giant); /* VFS */
|
||||||
if (vp)
|
if (vp)
|
||||||
@ -653,6 +658,7 @@ nfsrv_lookup(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
|||||||
}
|
}
|
||||||
|
|
||||||
nfsmout:
|
nfsmout:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
NFSD_UNLOCK();
|
NFSD_UNLOCK();
|
||||||
mtx_lock(&Giant); /* VFS */
|
mtx_lock(&Giant); /* VFS */
|
||||||
if (dirp)
|
if (dirp)
|
||||||
@ -771,6 +777,7 @@ nfsrv_readlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
|||||||
mb->m_next = mp3;
|
mb->m_next = mp3;
|
||||||
mp3 = NULL;
|
mp3 = NULL;
|
||||||
nfsmout:
|
nfsmout:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
if (mp3)
|
if (mp3)
|
||||||
m_freem(mp3);
|
m_freem(mp3);
|
||||||
if (vp) {
|
if (vp) {
|
||||||
@ -1040,6 +1047,7 @@ nfsrv_read(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
|||||||
}
|
}
|
||||||
*tl = txdr_unsigned(cnt);
|
*tl = txdr_unsigned(cnt);
|
||||||
nfsmout:
|
nfsmout:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
if (vp) {
|
if (vp) {
|
||||||
NFSD_UNLOCK();
|
NFSD_UNLOCK();
|
||||||
mtx_lock(&Giant); /* VFS */
|
mtx_lock(&Giant); /* VFS */
|
||||||
@ -1242,6 +1250,7 @@ nfsrv_write(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
|||||||
if (!error)
|
if (!error)
|
||||||
error = aftat_ret;
|
error = aftat_ret;
|
||||||
ereply:
|
ereply:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
nfsm_reply(NFSX_PREOPATTR(v3) + NFSX_POSTOPORFATTR(v3) +
|
nfsm_reply(NFSX_PREOPATTR(v3) + NFSX_POSTOPORFATTR(v3) +
|
||||||
2 * NFSX_UNSIGNED + NFSX_WRITEVERF(v3));
|
2 * NFSX_UNSIGNED + NFSX_WRITEVERF(v3));
|
||||||
if (v3) {
|
if (v3) {
|
||||||
@ -1275,6 +1284,7 @@ ereply:
|
|||||||
}
|
}
|
||||||
error = 0;
|
error = 0;
|
||||||
nfsmout:
|
nfsmout:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
NFSD_UNLOCK();
|
NFSD_UNLOCK();
|
||||||
mtx_lock(&Giant); /* VFS */
|
mtx_lock(&Giant); /* VFS */
|
||||||
if (vp)
|
if (vp)
|
||||||
@ -1386,6 +1396,7 @@ nfsrv_writegather(struct nfsrv_descript **ndp, struct nfssvc_sock *slp,
|
|||||||
}
|
}
|
||||||
if (len > NFS_MAXDATA || len < 0 || i < len) {
|
if (len > NFS_MAXDATA || len < 0 || i < len) {
|
||||||
nfsmout:
|
nfsmout:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
m_freem(mrep);
|
m_freem(mrep);
|
||||||
error = EIO;
|
error = EIO;
|
||||||
nfsm_writereply(2 * NFSX_UNSIGNED);
|
nfsm_writereply(2 * NFSX_UNSIGNED);
|
||||||
@ -1719,7 +1730,7 @@ nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
|||||||
nfsm_srvmtofh(fhp);
|
nfsm_srvmtofh(fhp);
|
||||||
if ((mp = vfs_getvfs(&fhp->fh_fsid)) == NULL) {
|
if ((mp = vfs_getvfs(&fhp->fh_fsid)) == NULL) {
|
||||||
error = ESTALE;
|
error = ESTALE;
|
||||||
goto ereply;
|
goto ereply_locked;
|
||||||
}
|
}
|
||||||
NFSD_UNLOCK();
|
NFSD_UNLOCK();
|
||||||
mtx_lock(&Giant); /* VFS */
|
mtx_lock(&Giant); /* VFS */
|
||||||
@ -1943,8 +1954,11 @@ nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ereply:
|
ereply:
|
||||||
|
NFSD_UNLOCK_ASSERT();
|
||||||
mtx_unlock(&Giant); /* VFS */
|
mtx_unlock(&Giant); /* VFS */
|
||||||
NFSD_LOCK();
|
NFSD_LOCK();
|
||||||
|
ereply_locked:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
nfsm_reply(NFSX_SRVFH(v3) + NFSX_FATTR(v3) + NFSX_WCCDATA(v3));
|
nfsm_reply(NFSX_SRVFH(v3) + NFSX_FATTR(v3) + NFSX_WCCDATA(v3));
|
||||||
if (v3) {
|
if (v3) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
@ -1961,6 +1975,7 @@ ereply:
|
|||||||
error = 0;
|
error = 0;
|
||||||
|
|
||||||
nfsmout:
|
nfsmout:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
NFSD_UNLOCK();
|
NFSD_UNLOCK();
|
||||||
mtx_lock(&Giant); /* VFS */
|
mtx_lock(&Giant); /* VFS */
|
||||||
if (nd.ni_startdir) {
|
if (nd.ni_startdir) {
|
||||||
@ -2116,6 +2131,7 @@ nfsrv_mknod(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
|||||||
* send response, cleanup, return.
|
* send response, cleanup, return.
|
||||||
*/
|
*/
|
||||||
out:
|
out:
|
||||||
|
NFSD_UNLOCK_ASSERT();
|
||||||
if (nd.ni_startdir) {
|
if (nd.ni_startdir) {
|
||||||
vrele(nd.ni_startdir);
|
vrele(nd.ni_startdir);
|
||||||
nd.ni_startdir = NULL;
|
nd.ni_startdir = NULL;
|
||||||
@ -2146,9 +2162,10 @@ out:
|
|||||||
diraft_ret = VOP_GETATTR(dirp, &diraft, cred, td);
|
diraft_ret = VOP_GETATTR(dirp, &diraft, cred, td);
|
||||||
VOP_UNLOCK(dirp, 0, td);
|
VOP_UNLOCK(dirp, 0, td);
|
||||||
}
|
}
|
||||||
ereply:
|
|
||||||
mtx_unlock(&Giant); /* VFS */
|
mtx_unlock(&Giant); /* VFS */
|
||||||
NFSD_LOCK();
|
NFSD_LOCK();
|
||||||
|
ereply:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
nfsm_reply(NFSX_SRVFH(1) + NFSX_POSTOPATTR(1) + NFSX_WCCDATA(1));
|
nfsm_reply(NFSX_SRVFH(1) + NFSX_POSTOPATTR(1) + NFSX_WCCDATA(1));
|
||||||
if (v3) {
|
if (v3) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
@ -2164,6 +2181,7 @@ ereply:
|
|||||||
NFSD_LOCK();
|
NFSD_LOCK();
|
||||||
return (0);
|
return (0);
|
||||||
nfsmout:
|
nfsmout:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
NFSD_UNLOCK();
|
NFSD_UNLOCK();
|
||||||
mtx_lock(&Giant); /* VFS */
|
mtx_lock(&Giant); /* VFS */
|
||||||
if (dirp)
|
if (dirp)
|
||||||
@ -2249,6 +2267,7 @@ nfsrv_remove(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
|
NFSD_UNLOCK_ASSERT();
|
||||||
if (!error) {
|
if (!error) {
|
||||||
error = VOP_REMOVE(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
|
error = VOP_REMOVE(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
|
||||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||||
@ -2280,12 +2299,14 @@ out:
|
|||||||
mtx_unlock(&Giant); /* VFS */
|
mtx_unlock(&Giant); /* VFS */
|
||||||
NFSD_LOCK();
|
NFSD_LOCK();
|
||||||
ereply:
|
ereply:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
nfsm_reply(NFSX_WCCDATA(v3));
|
nfsm_reply(NFSX_WCCDATA(v3));
|
||||||
if (v3) {
|
if (v3) {
|
||||||
nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
|
nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft);
|
||||||
error = 0;
|
error = 0;
|
||||||
}
|
}
|
||||||
nfsmout:
|
nfsmout:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
NFSD_UNLOCK();
|
NFSD_UNLOCK();
|
||||||
mtx_lock(&Giant); /* VFS */
|
mtx_lock(&Giant); /* VFS */
|
||||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||||
@ -2397,8 +2418,11 @@ nfsrv_rename(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
|||||||
vrele(tdirp);
|
vrele(tdirp);
|
||||||
tdirp = NULL;
|
tdirp = NULL;
|
||||||
}
|
}
|
||||||
if (error)
|
if (error) {
|
||||||
|
mtx_unlock(&Giant); /* VFS */
|
||||||
|
NFSD_LOCK();
|
||||||
goto out1;
|
goto out1;
|
||||||
|
}
|
||||||
|
|
||||||
tdvp = tond.ni_dvp;
|
tdvp = tond.ni_dvp;
|
||||||
tvp = tond.ni_vp;
|
tvp = tond.ni_vp;
|
||||||
@ -2455,6 +2479,7 @@ nfsrv_rename(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
|||||||
fromnd.ni_cnd.cn_namelen))
|
fromnd.ni_cnd.cn_namelen))
|
||||||
error = -1;
|
error = -1;
|
||||||
out:
|
out:
|
||||||
|
NFSD_UNLOCK_ASSERT();
|
||||||
if (!error) {
|
if (!error) {
|
||||||
/*
|
/*
|
||||||
* The VOP_RENAME function releases all vnode references &
|
* The VOP_RENAME function releases all vnode references &
|
||||||
@ -2477,9 +2502,10 @@ out:
|
|||||||
}
|
}
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
||||||
out1:
|
|
||||||
mtx_unlock(&Giant); /* VFS */
|
mtx_unlock(&Giant); /* VFS */
|
||||||
NFSD_LOCK();
|
NFSD_LOCK();
|
||||||
|
out1:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
nfsm_reply(2 * NFSX_WCCDATA(v3));
|
nfsm_reply(2 * NFSX_WCCDATA(v3));
|
||||||
if (v3) {
|
if (v3) {
|
||||||
/* Release existing locks to prevent deadlock. */
|
/* Release existing locks to prevent deadlock. */
|
||||||
@ -2518,6 +2544,7 @@ nfsmout:
|
|||||||
/*
|
/*
|
||||||
* Clear out tond related fields
|
* Clear out tond related fields
|
||||||
*/
|
*/
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
NFSD_UNLOCK();
|
NFSD_UNLOCK();
|
||||||
mtx_lock(&Giant); /* VFS */
|
mtx_lock(&Giant); /* VFS */
|
||||||
if (tdirp)
|
if (tdirp)
|
||||||
@ -2680,6 +2707,7 @@ out2:
|
|||||||
mtx_unlock(&Giant); /* VFS */
|
mtx_unlock(&Giant); /* VFS */
|
||||||
NFSD_LOCK();
|
NFSD_LOCK();
|
||||||
ereply:
|
ereply:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3));
|
nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3));
|
||||||
if (v3) {
|
if (v3) {
|
||||||
nfsm_srvpostop_attr(getret, &at);
|
nfsm_srvpostop_attr(getret, &at);
|
||||||
@ -2689,6 +2717,7 @@ ereply:
|
|||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
||||||
nfsmout:
|
nfsmout:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
NFSD_UNLOCK();
|
NFSD_UNLOCK();
|
||||||
mtx_lock(&Giant); /* VFS */
|
mtx_lock(&Giant); /* VFS */
|
||||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||||
@ -2744,6 +2773,8 @@ nfsrv_symlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
|||||||
fhp = &nfh.fh_generic;
|
fhp = &nfh.fh_generic;
|
||||||
nfsm_srvmtofh(fhp);
|
nfsm_srvmtofh(fhp);
|
||||||
if ((mp = vfs_getvfs(&fhp->fh_fsid)) == NULL) {
|
if ((mp = vfs_getvfs(&fhp->fh_fsid)) == NULL) {
|
||||||
|
NFSD_UNLOCK();
|
||||||
|
mtx_lock(&Giant); /* VFS */
|
||||||
error = ESTALE;
|
error = ESTALE;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -2841,6 +2872,7 @@ nfsrv_symlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
|
NFSD_UNLOCK_ASSERT();
|
||||||
/*
|
/*
|
||||||
* These releases aren't strictly required, does even doing them
|
* These releases aren't strictly required, does even doing them
|
||||||
* make any sense? XXX can nfsm_reply() block?
|
* make any sense? XXX can nfsm_reply() block?
|
||||||
@ -2872,6 +2904,7 @@ out:
|
|||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
||||||
nfsmout:
|
nfsmout:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
NFSD_UNLOCK();
|
NFSD_UNLOCK();
|
||||||
mtx_lock(&Giant); /* VFS */
|
mtx_lock(&Giant); /* VFS */
|
||||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||||
@ -2930,6 +2963,8 @@ nfsrv_mkdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
|||||||
fhp = &nfh.fh_generic;
|
fhp = &nfh.fh_generic;
|
||||||
nfsm_srvmtofh(fhp);
|
nfsm_srvmtofh(fhp);
|
||||||
if ((mp = vfs_getvfs(&fhp->fh_fsid)) == NULL) {
|
if ((mp = vfs_getvfs(&fhp->fh_fsid)) == NULL) {
|
||||||
|
NFSD_UNLOCK();
|
||||||
|
mtx_lock(&Giant); /* VFS */
|
||||||
error = ESTALE;
|
error = ESTALE;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -3004,6 +3039,7 @@ nfsrv_mkdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
|||||||
error = VOP_GETATTR(nd.ni_vp, vap, cred, td);
|
error = VOP_GETATTR(nd.ni_vp, vap, cred, td);
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
|
NFSD_UNLOCK_ASSERT();
|
||||||
if (dirp) {
|
if (dirp) {
|
||||||
if (dirp == nd.ni_dvp) {
|
if (dirp == nd.ni_dvp) {
|
||||||
diraft_ret = VOP_GETATTR(dirp, &diraft, cred, td);
|
diraft_ret = VOP_GETATTR(dirp, &diraft, cred, td);
|
||||||
@ -3048,6 +3084,7 @@ out:
|
|||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
||||||
nfsmout:
|
nfsmout:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
NFSD_UNLOCK();
|
NFSD_UNLOCK();
|
||||||
mtx_lock(&Giant); /* VFS */
|
mtx_lock(&Giant); /* VFS */
|
||||||
if (dirp)
|
if (dirp)
|
||||||
@ -3152,6 +3189,7 @@ out:
|
|||||||
* Issue or abort op. Since SAVESTART is not set, path name
|
* Issue or abort op. Since SAVESTART is not set, path name
|
||||||
* component is freed by the VOP after either.
|
* component is freed by the VOP after either.
|
||||||
*/
|
*/
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
NFSD_UNLOCK();
|
NFSD_UNLOCK();
|
||||||
mtx_lock(&Giant); /* VFS */
|
mtx_lock(&Giant); /* VFS */
|
||||||
if (!error)
|
if (!error)
|
||||||
@ -3187,6 +3225,7 @@ out:
|
|||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
||||||
nfsmout:
|
nfsmout:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
NFSD_UNLOCK();
|
NFSD_UNLOCK();
|
||||||
mtx_lock(&Giant); /* VFS */
|
mtx_lock(&Giant); /* VFS */
|
||||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||||
@ -3356,6 +3395,7 @@ nfsrv_readdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
|||||||
*/
|
*/
|
||||||
MALLOC(rbuf, caddr_t, siz, M_TEMP, M_WAITOK);
|
MALLOC(rbuf, caddr_t, siz, M_TEMP, M_WAITOK);
|
||||||
again:
|
again:
|
||||||
|
NFSD_UNLOCK_ASSERT();
|
||||||
iv.iov_base = rbuf;
|
iv.iov_base = rbuf;
|
||||||
iv.iov_len = fullsiz;
|
iv.iov_len = fullsiz;
|
||||||
io.uio_iov = &iv;
|
io.uio_iov = &iv;
|
||||||
@ -3556,6 +3596,7 @@ again:
|
|||||||
FREE((caddr_t)cookies, M_TEMP);
|
FREE((caddr_t)cookies, M_TEMP);
|
||||||
|
|
||||||
nfsmout:
|
nfsmout:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
if (vp) {
|
if (vp) {
|
||||||
NFSD_UNLOCK();
|
NFSD_UNLOCK();
|
||||||
mtx_lock(&Giant); /* VFS */
|
mtx_lock(&Giant); /* VFS */
|
||||||
@ -3664,6 +3705,7 @@ nfsrv_readdirplus(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
|||||||
VOP_UNLOCK(vp, 0, td);
|
VOP_UNLOCK(vp, 0, td);
|
||||||
MALLOC(rbuf, caddr_t, siz, M_TEMP, M_WAITOK);
|
MALLOC(rbuf, caddr_t, siz, M_TEMP, M_WAITOK);
|
||||||
again:
|
again:
|
||||||
|
NFSD_UNLOCK_ASSERT();
|
||||||
iv.iov_base = rbuf;
|
iv.iov_base = rbuf;
|
||||||
iv.iov_len = fullsiz;
|
iv.iov_len = fullsiz;
|
||||||
io.uio_iov = &iv;
|
io.uio_iov = &iv;
|
||||||
@ -3897,6 +3939,7 @@ again:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
invalid:
|
invalid:
|
||||||
|
NFSD_UNLOCK_ASSERT();
|
||||||
cpos += dp->d_reclen;
|
cpos += dp->d_reclen;
|
||||||
dp = (struct dirent *)cpos;
|
dp = (struct dirent *)cpos;
|
||||||
cookiep++;
|
cookiep++;
|
||||||
@ -3923,6 +3966,7 @@ invalid:
|
|||||||
FREE((caddr_t)cookies, M_TEMP);
|
FREE((caddr_t)cookies, M_TEMP);
|
||||||
FREE((caddr_t)rbuf, M_TEMP);
|
FREE((caddr_t)rbuf, M_TEMP);
|
||||||
nfsmout:
|
nfsmout:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
if (vp) {
|
if (vp) {
|
||||||
NFSD_UNLOCK();
|
NFSD_UNLOCK();
|
||||||
mtx_lock(&Giant); /* VFS */
|
mtx_lock(&Giant); /* VFS */
|
||||||
@ -4081,6 +4125,7 @@ nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
|||||||
vp = NULL;
|
vp = NULL;
|
||||||
NFSD_LOCK();
|
NFSD_LOCK();
|
||||||
ereply:
|
ereply:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
nfsm_reply(NFSX_V3WCCDATA + NFSX_V3WRITEVERF);
|
nfsm_reply(NFSX_V3WCCDATA + NFSX_V3WRITEVERF);
|
||||||
nfsm_srvwcc_data(for_ret, &bfor, aft_ret, &aft);
|
nfsm_srvwcc_data(for_ret, &bfor, aft_ret, &aft);
|
||||||
if (!error) {
|
if (!error) {
|
||||||
@ -4093,6 +4138,7 @@ ereply:
|
|||||||
error = 0;
|
error = 0;
|
||||||
}
|
}
|
||||||
nfsmout:
|
nfsmout:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
NFSD_UNLOCK();
|
NFSD_UNLOCK();
|
||||||
mtx_lock(&Giant); /* VFS */
|
mtx_lock(&Giant); /* VFS */
|
||||||
if (vp)
|
if (vp)
|
||||||
@ -4194,6 +4240,7 @@ nfsrv_statfs(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
|||||||
sfp->sf_bavail = txdr_unsigned(sf->f_bavail);
|
sfp->sf_bavail = txdr_unsigned(sf->f_bavail);
|
||||||
}
|
}
|
||||||
nfsmout:
|
nfsmout:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
if (vp) {
|
if (vp) {
|
||||||
NFSD_UNLOCK();
|
NFSD_UNLOCK();
|
||||||
mtx_lock(&Giant); /* VFS */
|
mtx_lock(&Giant); /* VFS */
|
||||||
@ -4280,6 +4327,7 @@ nfsrv_fsinfo(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
|||||||
NFSV3FSINFO_SYMLINK | NFSV3FSINFO_HOMOGENEOUS |
|
NFSV3FSINFO_SYMLINK | NFSV3FSINFO_HOMOGENEOUS |
|
||||||
NFSV3FSINFO_CANSETTIME);
|
NFSV3FSINFO_CANSETTIME);
|
||||||
nfsmout:
|
nfsmout:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
if (vp) {
|
if (vp) {
|
||||||
NFSD_UNLOCK();
|
NFSD_UNLOCK();
|
||||||
mtx_lock(&Giant); /* VFS */
|
mtx_lock(&Giant); /* VFS */
|
||||||
@ -4361,6 +4409,7 @@ nfsrv_pathconf(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
|||||||
pc->pc_caseinsensitive = nfsrv_nfs_false;
|
pc->pc_caseinsensitive = nfsrv_nfs_false;
|
||||||
pc->pc_casepreserving = nfsrv_nfs_true;
|
pc->pc_casepreserving = nfsrv_nfs_true;
|
||||||
nfsmout:
|
nfsmout:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
if (vp) {
|
if (vp) {
|
||||||
NFSD_UNLOCK();
|
NFSD_UNLOCK();
|
||||||
mtx_lock(&Giant); /* VFS */
|
mtx_lock(&Giant); /* VFS */
|
||||||
@ -4389,6 +4438,7 @@ nfsrv_null(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
|||||||
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
|
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
|
||||||
nfsm_reply(0);
|
nfsm_reply(0);
|
||||||
nfsmout:
|
nfsmout:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4415,6 +4465,7 @@ nfsrv_noop(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp,
|
|||||||
nfsm_reply(0);
|
nfsm_reply(0);
|
||||||
error = 0;
|
error = 0;
|
||||||
nfsmout:
|
nfsmout:
|
||||||
|
NFSD_LOCK_ASSERT();
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4440,7 +4491,6 @@ nfsrv_access(struct vnode *vp, int flags, struct ucred *cred, int rdonly,
|
|||||||
int error;
|
int error;
|
||||||
|
|
||||||
NFSD_LOCK_ASSERT();
|
NFSD_LOCK_ASSERT();
|
||||||
NFSD_UNLOCK();
|
|
||||||
|
|
||||||
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
|
nfsdbprintf(("%s %d\n", __FILE__, __LINE__));
|
||||||
if (flags & VWRITE) {
|
if (flags & VWRITE) {
|
||||||
@ -4455,8 +4505,7 @@ nfsrv_access(struct vnode *vp, int flags, struct ucred *cred, int rdonly,
|
|||||||
case VREG:
|
case VREG:
|
||||||
case VDIR:
|
case VDIR:
|
||||||
case VLNK:
|
case VLNK:
|
||||||
error = EROFS;
|
return (EROFS);
|
||||||
goto out;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -4465,15 +4514,14 @@ nfsrv_access(struct vnode *vp, int flags, struct ucred *cred, int rdonly,
|
|||||||
* If there's shared text associated with
|
* If there's shared text associated with
|
||||||
* the inode, we can't allow writing.
|
* the inode, we can't allow writing.
|
||||||
*/
|
*/
|
||||||
if (vp->v_vflag & VV_TEXT) {
|
if (vp->v_vflag & VV_TEXT)
|
||||||
NFSD_LOCK();
|
|
||||||
return (ETXTBSY);
|
return (ETXTBSY);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
NFSD_UNLOCK();
|
||||||
mtx_lock(&Giant); /* VFS */
|
mtx_lock(&Giant); /* VFS */
|
||||||
error = VOP_GETATTR(vp, &vattr, cred, td);
|
error = VOP_GETATTR(vp, &vattr, cred, td);
|
||||||
if (error)
|
if (error)
|
||||||
goto out2;
|
goto out;
|
||||||
error = VOP_ACCESS(vp, flags, cred, td);
|
error = VOP_ACCESS(vp, flags, cred, td);
|
||||||
/*
|
/*
|
||||||
* Allow certain operations for the owner (reads and writes
|
* Allow certain operations for the owner (reads and writes
|
||||||
@ -4481,9 +4529,9 @@ nfsrv_access(struct vnode *vp, int flags, struct ucred *cred, int rdonly,
|
|||||||
*/
|
*/
|
||||||
if (override && error == EACCES && cred->cr_uid == vattr.va_uid)
|
if (override && error == EACCES && cred->cr_uid == vattr.va_uid)
|
||||||
error = 0;
|
error = 0;
|
||||||
out2:
|
|
||||||
mtx_unlock(&Giant); /* VFS */
|
|
||||||
out:
|
out:
|
||||||
|
NFSD_UNLOCK_ASSERT();
|
||||||
|
mtx_unlock(&Giant); /* VFS */
|
||||||
NFSD_LOCK();
|
NFSD_LOCK();
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user