Possible dereference in fs/nfsd/nfs4callback.c
PATCH 1/1 Possible dereference in fs/nfsd/nfs4callback.c
hi,
the following commit introduced a possible NULL pointer dereference
http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=ae5c79476f36512d1100e162606bb5691f2cce5a
we set cb->cb_client to NULL and pass it to rpc_shutdown_client() which dereferences it. The easy fix below.
fs/nfsd/nfs4callback.c renamed from fs/nfsd/nfs4callback.c.orig +2 -1
@@ -450,7 +450,8 @@ out_rpciod:rpciod_down (); cb->cb_client =NULL ; out_clnt: -rpc_shutdown_client (cb->cb_client); +if (cb->cb_client) +rpc_shutdown_client (cb->cb_client); out_err:dprintk ("NFSD: warning: no callback path to client %.*s\n" , (int )clp->cl_name.len, clp->cl_name.data);
Quoted 6 lines · Eric Sesterhenn
hi,
the following commit introduced a possible NULL pointer dereference
http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=ae5c79476f36512d1100e162606bb5691f2cce5awe set
cb->cb_clientto NULL and pass it torpc_shutdown_client()which dereferences it.
What was I thinking/smoking? ;-)
Quoted 7 lines
The easy fix below.
Signed-off-by Eric Sesterhenn <[email protected]>
fs/nfsd/nfs4callback.c out_rpciod: · line 457
Quoted 9 lines
fs/nfsd/nfs4callback.c renamed from fs/nfsd/nfs4callback.c.orig +2
-1@@ -450,7 +450,8 @@ out_rpciod:rpciod_down (); cb->cb_client =NULL ; out_clnt: -rpc_shutdown_client (cb->cb_client); +if (cb->cb_client) +rpc_shutdown_client (cb->cb_client); out_err:dprintk ("NFSD: warning: no callback path to client %.*s\n" , (int )clp->cl_name.len, clp->cl_name.data);
Actually I see another problem here.
rpc_create() doesn't return NULL, it returns an ERR_PTR. So the return code check in the code just before this is also bogus.
I'll send a complete fix through Trond.
fs/nfsd/nfs4callback.c out_rpciod: · line 454
Quoted 7 lines · Eric Sesterhenn
we set
cb->cb_clientto NULL and pass it torpc_shutdown_client()which dereferences it. The easy fix below.
out_clnt:fs/nfsd/nfs4callback.c renamed from fs/nfsd/nfs4callback.c.orig +2
-1-rpc_shutdown_client (cb->cb_client); +if (cb->cb_client) +rpc_shutdown_client (cb->cb_client);
OK, I admit not knowing the NFS code well, but this one looks suspiciously like "easy paper-over" rather than "easy fix". Is there other cod elsewhere that guards this case from ever actually happening? If it *does* happen, is it indicative of major borkage and we really should do something like:
if (cb->cb_client) rpm_shutdown_client(cb->cb_client) else printk(KERN_ERR "Yowza - trashed NFS control structures...");
or even maybe a more drastic action (oops/panic)?