From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
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>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
David Rientjes <rientjes@google.com>
Subject: Re: [PATCH] zsmalloc: fix a null pointer dereference in destroy_handle_cache()
Date: Tue, 9 Jun 2015 12:57:17 +0900 [thread overview]
Message-ID: <20150609035717.GB3297@swordfish> (raw)
In-Reply-To: <20150608135532.ac913746b6394217e92a229a@linux-foundation.org>
On (06/08/15 13:55), Andrew Morton 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.
>
Oh, sorry I first received "+ zsmalloc-fix-a-null-pointer-dereference-in-
destroy_handle_cache.patch added to -mm tree" message, so I replied
there. fetchmail works somewhat confusing over the last weeks.
> > ...
> >
> > --- 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.
Yes, I thought about this.
A naive grepping gave me 563 occurrences
git grep kmem_cache_destroy | wc -l
563
So I decided to hold this activity. Well, I think I can create this
patch bomb, it's trivial.
-ss
--
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>
next prev parent reply other threads:[~2015-06-09 3:56 UTC|newest]
Thread overview: 6+ 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-08 20:55 ` Andrew Morton
2015-06-09 0:38 ` Joonsoo Kim
2015-06-09 0:43 ` Andrew Morton
2015-06-09 3:57 ` Sergey Senozhatsky [this message]
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=20150609035717.GB3297@swordfish \
--to=sergey.senozhatsky.work@gmail.com \
--cc=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@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).