diff mbox

nfsd: Detect unhashed stids in nfsd4_verify_open_stid()

Message ID 20180112224230.129322-1-trond.myklebust@primarydata.com (mailing list archive)
State New, archived
Headers show

Commit Message

Trond Myklebust Jan. 12, 2018, 10:42 p.m. UTC
The state of the stid is guaranteed by 2 locks:
- The nfs4_client 'cl_lock' spinlock
- The nfs4_ol_stateid 'st_mutex' mutex

so it is quite possible for the stid to be unhashed after lookup,
but before calling nfsd4_lock_ol_stateid(). So we do need to check
for a zero value for 'sc_type' in nfsd4_verify_open_stid().

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
---
 fs/nfsd/nfs4state.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Chuck Lever Jan. 13, 2018, 2:15 a.m. UTC | #1
> On Jan 12, 2018, at 5:42 PM, Trond Myklebust <trond.myklebust@primarydata.com> wrote:
> 
> The state of the stid is guaranteed by 2 locks:
> - The nfs4_client 'cl_lock' spinlock
> - The nfs4_ol_stateid 'st_mutex' mutex
> 
> so it is quite possible for the stid to be unhashed after lookup,
> but before calling nfsd4_lock_ol_stateid(). So we do need to check
> for a zero value for 'sc_type' in nfsd4_verify_open_stid().
> 
> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>

Three successful passes of the git regression suite on NFSv4.1
Three successful passes of xfstests on NFSv4.1

Tested-by: Chuck Lever <chuck.lever@oracle.com>


> ---
> fs/nfsd/nfs4state.c | 1 +
> 1 file changed, 1 insertion(+)
> 
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 8d53d29161f5..b5bda115f6a9 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -3591,6 +3591,7 @@ nfsd4_verify_open_stid(struct nfs4_stid *s)
> 	switch (s->sc_type) {
> 	default:
> 		break;
> +	case 0:
> 	case NFS4_CLOSED_STID:
> 	case NFS4_CLOSED_DELEG_STID:
> 		ret = nfserr_bad_stateid;
> -- 
> 2.14.3
> 

--
Chuck Lever



--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 8d53d29161f5..b5bda115f6a9 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -3591,6 +3591,7 @@  nfsd4_verify_open_stid(struct nfs4_stid *s)
 	switch (s->sc_type) {
 	default:
 		break;
+	case 0:
 	case NFS4_CLOSED_STID:
 	case NFS4_CLOSED_DELEG_STID:
 		ret = nfserr_bad_stateid;