public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] sunrpc: add missing return statement
@ 2010-05-04 11:59 Johannes Weiner
  2010-05-04 12:27 ` Trond Myklebust
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Weiner @ 2010-05-04 11:59 UTC (permalink / raw)
  To: David S. Miller
  Cc: Alexandros Batsakis, linux-nfs-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

f300bab "nfsd41: sunrpc: add new xprt class for nfsv4.1 backchannel"
introduced an error case branch that lacks an actual `return' keyword
before the return value.  Add it.

Signed-off-by: Johannes Weiner <jw-QdrG9jWwCLEAvxtiuMwx3w@public.gmane.org>
Cc: Alexandros Batsakis <batsakis-HgOvQuBEEgTQT0dZR+AlfA@public.gmane.org>
---
 net/sunrpc/xprtsock.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -2444,7 +2444,7 @@ static struct rpc_xprt *xs_setup_bc_tcp(
 	struct svc_sock *bc_sock;
 
 	if (!args->bc_xprt)
-		ERR_PTR(-EINVAL);
+		return ERR_PTR(-EINVAL);
 
 	xprt = xs_setup_xprt(args, xprt_tcp_slot_table_entries);
 	if (IS_ERR(xprt))
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [patch] sunrpc: add missing return statement
  2010-05-04 11:59 [patch] sunrpc: add missing return statement Johannes Weiner
@ 2010-05-04 12:27 ` Trond Myklebust
       [not found]   ` <1272976042.7559.24.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Trond Myklebust @ 2010-05-04 12:27 UTC (permalink / raw)
  To: Johannes Weiner
  Cc: David S. Miller, Alexandros Batsakis, linux-nfs, netdev,
	linux-kernel

On Tue, 2010-05-04 at 13:59 +0200, Johannes Weiner wrote: 
> f300bab "nfsd41: sunrpc: add new xprt class for nfsv4.1 backchannel"
> introduced an error case branch that lacks an actual `return' keyword
> before the return value.  Add it.
> 
> Signed-off-by: Johannes Weiner <jw@emlix.com>
> Cc: Alexandros Batsakis <batsakis@netapp.com>
> ---
>  net/sunrpc/xprtsock.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> --- a/net/sunrpc/xprtsock.c
> +++ b/net/sunrpc/xprtsock.c
> @@ -2444,7 +2444,7 @@ static struct rpc_xprt *xs_setup_bc_tcp(
>  	struct svc_sock *bc_sock;
>  
>  	if (!args->bc_xprt)
> -		ERR_PTR(-EINVAL);
> +		return ERR_PTR(-EINVAL);
>  
>  	xprt = xs_setup_xprt(args, xprt_tcp_slot_table_entries);
>  	if (IS_ERR(xprt))

No. It should either be a BUG_ON(), or else be removed entirely.
Returning an error value for something that is clearly a programming bug
is not a particularly useful exercise...

Cheers
  Trond

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

* Re: [patch] sunrpc: add missing return statement
       [not found]   ` <1272976042.7559.24.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
@ 2010-05-04 13:03     ` Tetsuo Handa
  2010-05-04 13:13       ` Trond Myklebust
  0 siblings, 1 reply; 5+ messages in thread
From: Tetsuo Handa @ 2010-05-04 13:03 UTC (permalink / raw)
  To: trond.myklebust-41N18TsMXrtuMpJDpNschA, jw-QdrG9jWwCLEAvxtiuMwx3w
  Cc: davem-fT/PcQaiUtIeIZ0/mPfg9Q, batsakis-HgOvQuBEEgTQT0dZR+AlfA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

Trond Myklebust wrote:
> On Tue, 2010-05-04 at 13:59 +0200, Johannes Weiner wrote: 
> > f300bab "nfsd41: sunrpc: add new xprt class for nfsv4.1 backchannel"
> > introduced an error case branch that lacks an actual `return' keyword
> > before the return value.  Add it.
> > 
> > Signed-off-by: Johannes Weiner <jw-QdrG9jWwCLEAvxtiuMwx3w@public.gmane.org>
> > Cc: Alexandros Batsakis <batsakis-HgOvQuBEEgTQT0dZR+AlfA@public.gmane.org>
> > ---
> >  net/sunrpc/xprtsock.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > --- a/net/sunrpc/xprtsock.c
> > +++ b/net/sunrpc/xprtsock.c
> > @@ -2444,7 +2444,7 @@ static struct rpc_xprt *xs_setup_bc_tcp(
> >  	struct svc_sock *bc_sock;
> >  
> >  	if (!args->bc_xprt)
> > -		ERR_PTR(-EINVAL);
> > +		return ERR_PTR(-EINVAL);
> >  
> >  	xprt = xs_setup_xprt(args, xprt_tcp_slot_table_entries);
> >  	if (IS_ERR(xprt))
> 
> No. It should either be a BUG_ON(), or else be removed entirely.
> Returning an error value for something that is clearly a programming bug
> is not a particularly useful exercise...
> 
Removing NULL check is wrong because it will NULL pointer dereference later.

Tetsuo Handa wrote:
> Jani Nikula wrote:
> > Signed-off-by: Jani Nikula <ext-jani.1.nikula-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
> > 
> > ---
> > 
> > NOTE: I'm afraid I'm unable to test this; please consider this more a
> > bug report than a complete patch.
> > ---
> Indeed, it has to be "return ERR_PTR(-EINVAL);".
> Otherwise, it will trigger NULL pointer dereference some lines later.
> 
>     bc_sock = container_of(args->bc_xprt, struct svc_sock, sk_xprt);
>     bc_sock->sk_bc_xprt = xprt;
> 
> This bug was introduced by f300baba5a1536070d6d77bf0c8c4ca999bb4f0f
> "nfsd41: sunrpc: add new xprt class for nfsv4.1 backchannel" and
> exists in 2.6.32 and later.
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [patch] sunrpc: add missing return statement
  2010-05-04 13:03     ` Tetsuo Handa
@ 2010-05-04 13:13       ` Trond Myklebust
       [not found]         ` <1272978815.7559.27.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Trond Myklebust @ 2010-05-04 13:13 UTC (permalink / raw)
  To: Tetsuo Handa; +Cc: jw, davem, batsakis, linux-nfs, netdev, linux-kernel

On Tue, 2010-05-04 at 22:03 +0900, Tetsuo Handa wrote: 
> Trond Myklebust wrote:
> > On Tue, 2010-05-04 at 13:59 +0200, Johannes Weiner wrote: 
> > > f300bab "nfsd41: sunrpc: add new xprt class for nfsv4.1 backchannel"
> > > introduced an error case branch that lacks an actual `return' keyword
> > > before the return value.  Add it.
> > > 
> > > Signed-off-by: Johannes Weiner <jw@emlix.com>
> > > Cc: Alexandros Batsakis <batsakis@netapp.com>
> > > ---
> > >  net/sunrpc/xprtsock.c |    2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > --- a/net/sunrpc/xprtsock.c
> > > +++ b/net/sunrpc/xprtsock.c
> > > @@ -2444,7 +2444,7 @@ static struct rpc_xprt *xs_setup_bc_tcp(
> > >  	struct svc_sock *bc_sock;
> > >  
> > >  	if (!args->bc_xprt)
> > > -		ERR_PTR(-EINVAL);
> > > +		return ERR_PTR(-EINVAL);
> > >  
> > >  	xprt = xs_setup_xprt(args, xprt_tcp_slot_table_entries);
> > >  	if (IS_ERR(xprt))
> > 
> > No. It should either be a BUG_ON(), or else be removed entirely.
> > Returning an error value for something that is clearly a programming bug
> > is not a particularly useful exercise...
> > 
> Removing NULL check is wrong because it will NULL pointer dereference later.

Wrong. Removing NULL check is _right_ because calling this function
without setting up a back channel first is a major BUG. Returning an
error value to the user is pointless, since the user has no control over
this. It is entirely under control of the sunrpc developers...

Trond


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

* Re: [patch] sunrpc: add missing return statement
       [not found]         ` <1272978815.7559.27.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
@ 2010-05-04 14:02           ` Tetsuo Handa
  0 siblings, 0 replies; 5+ messages in thread
From: Tetsuo Handa @ 2010-05-04 14:02 UTC (permalink / raw)
  To: trond.myklebust-41N18TsMXrtuMpJDpNschA
  Cc: jw-QdrG9jWwCLEAvxtiuMwx3w, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
	batsakis-HgOvQuBEEgTQT0dZR+AlfA, linux-nfs-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

Trond Myklebust wrote:
> > > No. It should either be a BUG_ON(), or else be removed entirely.
> > > Returning an error value for something that is clearly a programming bug
> > > is not a particularly useful exercise...
> > > 
> > Removing NULL check is wrong because it will NULL pointer dereference later.
> 
> Wrong. Removing NULL check is _right_ because calling this function
> without setting up a back channel first is a major BUG. Returning an
> error value to the user is pointless, since the user has no control over
> this. It is entirely under control of the sunrpc developers...
> 
For security people, removing

	if (!args->bc_xprt)
		ERR_PTR(-EINVAL);

is worse and changing to

	BUG_ON(!args->bc_xprt);

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

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

end of thread, other threads:[~2010-05-04 14:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-04 11:59 [patch] sunrpc: add missing return statement Johannes Weiner
2010-05-04 12:27 ` Trond Myklebust
     [not found]   ` <1272976042.7559.24.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-05-04 13:03     ` Tetsuo Handa
2010-05-04 13:13       ` Trond Myklebust
     [not found]         ` <1272978815.7559.27.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-05-04 14:02           ` Tetsuo Handa

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