Commit 6e1402a2 authored by Benjamin Coddington's avatar Benjamin Coddington Committed by Luis Henriques

nfs4: start callback_ident at idr 1

commit c68a027c upstream.

If clp->cl_cb_ident is zero, then nfs_cb_idr_remove_locked() skips removing
it when the nfs_client is freed.  A decoding or server bug can then find
and try to put that first nfs_client which would lead to a crash.
Signed-off-by: default avatarBenjamin Coddington <bcodding@redhat.com>
Fixes: d6870312 ("nfs4client: convert to idr_alloc()")
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent afee648d
...@@ -33,7 +33,7 @@ static int nfs_get_cb_ident_idr(struct nfs_client *clp, int minorversion) ...@@ -33,7 +33,7 @@ static int nfs_get_cb_ident_idr(struct nfs_client *clp, int minorversion)
return ret; return ret;
idr_preload(GFP_KERNEL); idr_preload(GFP_KERNEL);
spin_lock(&nn->nfs_client_lock); spin_lock(&nn->nfs_client_lock);
ret = idr_alloc(&nn->cb_ident_idr, clp, 0, 0, GFP_NOWAIT); ret = idr_alloc(&nn->cb_ident_idr, clp, 1, 0, GFP_NOWAIT);
if (ret >= 0) if (ret >= 0)
clp->cl_cb_ident = ret; clp->cl_cb_ident = ret;
spin_unlock(&nn->nfs_client_lock); spin_unlock(&nn->nfs_client_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment