lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080522160323.GB8447@joi>
Date:	Thu, 22 May 2008 18:03:27 +0200
From:	Marcin Slusarz <marcin.slusarz@...il.com>
To:	Alexey Dobriyan <adobriyan@...il.com>
Cc:	LKML <linux-kernel@...r.kernel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Al Viro <viro@...IV.linux.org.uk>,
	Christoph Hellwig <hch@....de>, tom@...ngridcomputing.com
Subject: Re: [PATCH 1/6] ERR_PTR: if errno value is known at compile time,
	make sure it's valid

On Mon, May 19, 2008 at 10:38:52AM +0400, Alexey Dobriyan wrote:
> On Sun, May 18, 2008 at 11:56:53PM +0200, Marcin Slusarz wrote:
> > ERR_PTR is easy to call with wrong argument (positive errno),
> > and this error lead to catastrophic event - oops or kernel panic
> > (dereference of invalid pointer).
> > 
> > As most of error handling code paths are rarely tested, this kind of
> > bug can be hidden for years.
> > 
> > (Currently there are > 1400 calls of ERR_PTR with constant argument.)
> 
> > --- a/include/linux/err.h
> > +++ b/include/linux/err.h
> > @@ -19,11 +19,13 @@
> >  
> >  #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
> >  
> > -static inline void *ERR_PTR(long error)
> > +static inline void *__ERR_PTR(long error)
> >  {
> >  	return (void *) error;
> >  }
> >  
> > +#define ERR_PTR(error) (BUILD_BUG_ON(__builtin_constant_p(error) && !IS_ERR_VALUE(error)), __ERR_PTR(error))
> 
> This needs comment that this construct must be a macro, otherwise gcc
> does something stupid and doesn't break the build (at least in the case
> below).
Thanks, added to new version.

> BTW, I used grep(1) to find it.

http://lkml.org/lkml/2008/5/11/159

> 
> [PATCH] xprtrdma: fix ERR_PTR(E typo
> 
> Signed-off-by: Alexey Dobriyan <adobriyan@...il.com>
> ---
> 
>  net/sunrpc/xprtrdma/svc_rdma_transport.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
> +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
> @@ -661,7 +661,7 @@ static struct svc_xprt *svc_rdma_create(struct svc_serv *serv,
>  
>  	cma_xprt = rdma_create_xprt(serv, 1);
>  	if (!cma_xprt)
> -		return ERR_PTR(ENOMEM);
> +		return ERR_PTR(-ENOMEM);
>  	xprt = &cma_xprt->sc_xprt;
>  
>  	listen_id = rdma_create_id(rdma_listen_handler, cma_xprt, RDMA_PS_TCP);
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ