svn commit: r366120 - releng/12.2/sys/fs/nfsserver
Rick Macklem
rmacklem at FreeBSD.org
Thu Sep 24 16:21:32 UTC 2020
Author: rmacklem
Date: Thu Sep 24 16:21:30 2020
New Revision: 366120
URL: https://svnweb.freebsd.org/changeset/base/366120
Log:
MFS: r366050, r366117
Fix a LOR between the NFS server and server side krpc.
Recent testing of the NFS-over-TLS code found a LOR between the mutex lock
used for sessions and the sleep lock used for server side krpc socket
structures.
The code in nfsrv_checksequence() and nfsrv_bindconnsess() would call
SVC_RELEASE() with mutex(es) held. Normally this is ok, since
all that happens is SVC_RELEASE() decrements the reference count.
However, if the socket has just been shut
down, SVC_RELEASE() drops the reference count to 0 and acquires a sleep
lock during destruction of the server side krpc structure.
This patch fixes the problem by moving the SVC_RELEASE() call in
nfsrv_checksequence() and nfsrv_bindconnsess() down a few lines to
below where the mutex(es) are released.
Approved by: re (gjb)
Modified:
releng/12.2/sys/fs/nfsserver/nfs_nfsdstate.c
Directory Properties:
releng/12.2/ (props changed)
Modified: releng/12.2/sys/fs/nfsserver/nfs_nfsdstate.c
==============================================================================
--- releng/12.2/sys/fs/nfsserver/nfs_nfsdstate.c Thu Sep 24 16:11:53 2020 (r366119)
+++ releng/12.2/sys/fs/nfsserver/nfs_nfsdstate.c Thu Sep 24 16:21:30 2020 (r366120)
@@ -6214,6 +6214,7 @@ nfsrv_checksequence(struct nfsrv_descript *nd, uint32_
* bound as well, do the implicit binding unless a
* BindConnectiontoSession has already been done on the session.
*/
+ savxprt = NULL;
if (sep->sess_clp->lc_req.nr_client != NULL &&
sep->sess_cbsess.nfsess_xprt != nd->nd_xprt &&
(sep->sess_crflags & NFSV4CRSESS_CONNBACKCHAN) != 0 &&
@@ -6226,14 +6227,14 @@ nfsrv_checksequence(struct nfsrv_descript *nd, uint32_
sep->sess_clp->lc_req.nr_client->cl_private;
nd->nd_xprt->xp_idletimeout = 0; /* Disable timeout. */
sep->sess_cbsess.nfsess_xprt = nd->nd_xprt;
- if (savxprt != NULL)
- SVC_RELEASE(savxprt);
}
*sflagsp = 0;
if (sep->sess_clp->lc_req.nr_client == NULL)
*sflagsp |= NFSV4SEQ_CBPATHDOWN;
NFSUNLOCKSESSION(shp);
+ if (savxprt != NULL)
+ SVC_RELEASE(savxprt);
if (error == NFSERR_EXPIRED) {
*sflagsp |= NFSV4SEQ_EXPIREDALLSTATEREVOKED;
error = 0;
@@ -6404,6 +6405,7 @@ nfsrv_bindconnsess(struct nfsrv_descript *nd, uint8_t
int error;
error = 0;
+ savxprt = NULL;
shp = NFSSESSIONHASH(sessionid);
NFSLOCKSTATE();
NFSLOCKSESSION(shp);
@@ -6431,8 +6433,6 @@ nfsrv_bindconnsess(struct nfsrv_descript *nd, uint8_t
/* Disable idle timeout. */
nd->nd_xprt->xp_idletimeout = 0;
sep->sess_cbsess.nfsess_xprt = nd->nd_xprt;
- if (savxprt != NULL)
- SVC_RELEASE(savxprt);
sep->sess_crflags |= NFSV4CRSESS_CONNBACKCHAN;
clp->lc_flags |= LCL_DONEBINDCONN;
if (*foreaftp == NFSCDFS4_BACK)
@@ -6459,6 +6459,8 @@ nfsrv_bindconnsess(struct nfsrv_descript *nd, uint8_t
error = NFSERR_BADSESSION;
NFSUNLOCKSESSION(shp);
NFSUNLOCKSTATE();
+ if (savxprt != NULL)
+ SVC_RELEASE(savxprt);
return (error);
}
More information about the svn-src-all
mailing list