From: Andrew Morton <akpm@linux-foundation.org>
To: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Minchan Kim <minchan@kernel.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
Christoph Lameter <cl@linux.com>,
Pekka Enberg <penberg@kernel.org>,
David Rientjes <rientjes@google.com>
Subject: Re: [PATCH] zsmalloc: fix a null pointer dereference in destroy_handle_cache()
Date: Mon, 8 Jun 2015 17:43:06 -0700 [thread overview]
Message-ID: <20150608174306.92652579.akpm@linux-foundation.org> (raw)
In-Reply-To: <20150609003827.GD9687@js1304-P5Q-DELUXE>
On Tue, 9 Jun 2015 09:38:27 +0900 Joonsoo Kim <iamjoonsoo.kim@lge.com> wrote:
> > > ...
> > >
> > > --- 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.
Of course it's better - we have *hundreds* of sites doing something
which could be done at a single site. Where's the advantage in that?
> 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.
Maybe some of those should be converted as well.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
WARNING: multiple messages have this Message-ID (diff)
From: Andrew Morton <akpm@linux-foundation.org>
To: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Minchan Kim <minchan@kernel.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
Christoph Lameter <cl@linux.com>,
Pekka Enberg <penberg@kernel.org>,
David Rientjes <rientjes@google.com>
Subject: Re: [PATCH] zsmalloc: fix a null pointer dereference in destroy_handle_cache()
Date: Mon, 8 Jun 2015 17:43:06 -0700 [thread overview]
Message-ID: <20150608174306.92652579.akpm@linux-foundation.org> (raw)
In-Reply-To: <20150609003827.GD9687@js1304-P5Q-DELUXE>
On Tue, 9 Jun 2015 09:38:27 +0900 Joonsoo Kim <iamjoonsoo.kim@lge.com> wrote:
> > > ...
> > >
> > > --- 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.
Of course it's better - we have *hundreds* of sites doing something
which could be done at a single site. Where's the advantage in that?
> 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.
Maybe some of those should be converted as well.
next prev parent reply other threads:[~2015-06-09 0:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-05 11:11 [PATCH] zsmalloc: fix a null pointer dereference in destroy_handle_cache() Sergey Senozhatsky
2015-06-05 11:11 ` Sergey Senozhatsky
2015-06-08 20:55 ` Andrew Morton
2015-06-08 20:55 ` Andrew Morton
2015-06-09 0:38 ` Joonsoo Kim
2015-06-09 0:38 ` Joonsoo Kim
2015-06-09 0:43 ` Andrew Morton [this message]
2015-06-09 0:43 ` Andrew Morton
2015-06-09 3:57 ` Sergey Senozhatsky
2015-06-09 3:57 ` Sergey Senozhatsky
2015-06-10 0:03 ` Minchan Kim
2015-06-10 0:03 ` Minchan Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150608174306.92652579.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
--cc=sergey.senozhatsky.work@gmail.com \
--cc=sergey.senozhatsky@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.