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: <20150609003827.GD9687@js1304-P5Q-DELUXE>
Date:	Tue, 9 Jun 2015 09:38:27 +0900
From:	Joonsoo Kim <iamjoonsoo.kim@....com>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
	Minchan Kim <minchan@...nel.org>, linux-mm@...ck.org,
	linux-kernel@...r.kernel.org,
	Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>,
	Christoph Lameter <cl@...ux.com>,
	Pekka Enberg <penberg@...nel.org>,
	David Rientjes <rientjes@...gle.com>
Subject: Re: [PATCH] zsmalloc: fix a null pointer dereference in
 destroy_handle_cache()

On Mon, Jun 08, 2015 at 01:55:32PM -0700, Andrew Morton wrote:
> On Fri,  5 Jun 2015 20:11:30 +0900 Sergey Senozhatsky <sergey.senozhatsky@...il.com> wrote:
> 
> > zs_destroy_pool()->destroy_handle_cache() invoked from
> > zs_create_pool() can pass a NULL ->handle_cachep pointer
> > to kmem_cache_destroy(), which will dereference it.
> >
> 
> That's slightly lacking in details (under what circumstances will it
> crash) so I changed it to
> 
> : If zs_create_pool()->create_handle_cache()->kmem_cache_create() fails,
> : zs_create_pool()->destroy_handle_cache() will dereference the NULL
> : pool->handle_cachep.
> :
> : Modify destroy_handle_cache() to avoid this.
> 
> 
> > ...
> >
> > --- a/mm/zsmalloc.c
> > +++ b/mm/zsmalloc.c
> > @@ -285,7 +285,8 @@ static int create_handle_cache(struct zs_pool *pool)
> >  
> >  static void destroy_handle_cache(struct zs_pool *pool)
> >  {
> > -	kmem_cache_destroy(pool->handle_cachep);
> > +	if (pool->handle_cachep)
> > +		kmem_cache_destroy(pool->handle_cachep);
> >  }
> >  
> >  static unsigned long alloc_handle(struct zs_pool *pool)
> 
> I'll apply this, but...  from a bit of grepping I'm estimating that we
> have approximately 200 instances of
> 
> 	if (foo)
> 		kmem_cache_destroy(foo);
> 
> so obviously kmem_cache_destroy() should be doing the check.

Hello, Andrew.

I'm not sure if doing the check in kmem_cache_destroy() is better.
My quick grep for other pool based allocators(ex. mempool, zpool) also
says that they don't check whether passed pool pointer is NULL or not
in destroy function. I think that it's general convention that proper
pool pointer should be passed to pool based function APIs.

Thanks.
--
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