public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [Patch] Possible dereference in fs/nfsd/nfs4callback.c
@ 2006-09-26 10:30 Eric Sesterhenn
  2006-09-26 12:58 ` Chuck Lever
  2006-09-26 13:17 ` Valdis.Kletnieks
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Sesterhenn @ 2006-09-26 10:30 UTC (permalink / raw)
  To: linux-kernel; +Cc: chuck.lever

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.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.18-git5/fs/nfsd/nfs4callback.c.orig	2006-09-26 12:24:23.000000000 +0200
+++ linux-2.6.18-git5/fs/nfsd/nfs4callback.c	2006-09-26 12:24:40.000000000 +0200
@@ -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);



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch] Possible dereference in fs/nfsd/nfs4callback.c
  2006-09-26 10:30 [Patch] Possible dereference in fs/nfsd/nfs4callback.c Eric Sesterhenn
@ 2006-09-26 12:58 ` Chuck Lever
  2006-09-26 13:17 ` Valdis.Kletnieks
  1 sibling, 0 replies; 3+ messages in thread
From: Chuck Lever @ 2006-09-26 12:58 UTC (permalink / raw)
  To: Eric Sesterhenn; +Cc: linux-kernel

Eric Sesterhenn wrote:
> 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.

What was I thinking/smoking?  ;-)

> The easy fix below.
> 
> Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
> 
> --- linux-2.6.18-git5/fs/nfsd/nfs4callback.c.orig	2006-09-26 12:24:23.000000000 +0200
> +++ linux-2.6.18-git5/fs/nfsd/nfs4callback.c	2006-09-26 12:24:40.000000000 +0200
> @@ -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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch] Possible dereference in fs/nfsd/nfs4callback.c
  2006-09-26 10:30 [Patch] Possible dereference in fs/nfsd/nfs4callback.c Eric Sesterhenn
  2006-09-26 12:58 ` Chuck Lever
@ 2006-09-26 13:17 ` Valdis.Kletnieks
  1 sibling, 0 replies; 3+ messages in thread
From: Valdis.Kletnieks @ 2006-09-26 13:17 UTC (permalink / raw)
  To: Eric Sesterhenn; +Cc: linux-kernel, chuck.lever

[-- Attachment #1: Type: text/plain, Size: 770 bytes --]

On Tue, 26 Sep 2006 12:30:59 +0200, Eric Sesterhenn said:

> we set cb->cb_client to NULL and pass it to rpc_shutdown_client() which dereferences it.
> The easy fix below.

>  out_clnt:
> -	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)?

[-- Attachment #2: Type: application/pgp-signature, Size: 226 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-09-26 13:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-26 10:30 [Patch] Possible dereference in fs/nfsd/nfs4callback.c Eric Sesterhenn
2006-09-26 12:58 ` Chuck Lever
2006-09-26 13:17 ` Valdis.Kletnieks

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox