From: Andrew Morton <akpm@linux-foundation.org>
To: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: 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: Mon, 8 Jun 2015 13:55:32 -0700 [thread overview]
Message-ID: <20150608135532.ac913746b6394217e92a229a@linux-foundation.org> (raw)
In-Reply-To: <1433502690-2524-1-git-send-email-sergey.senozhatsky@gmail.com>
On Fri, 5 Jun 2015 20:11:30 +0900 Sergey Senozhatsky <sergey.senozhatsky@gmail.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.
--
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-08 20:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-05 11:11 Sergey Senozhatsky
2015-06-08 20:55 ` Andrew Morton [this message]
2015-06-09 0:38 ` Joonsoo Kim
2015-06-09 0:43 ` Andrew Morton
2015-06-09 3:57 ` Sergey Senozhatsky
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=20150608135532.ac913746b6394217e92a229a@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox