linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Christopher Lameter <cl@linux.com>
To: Dmitry Vyukov <dvyukov@google.com>
Cc: syzbot <syzbot+d6ed4ec679652b4fd4e4@syzkaller.appspotmail.com>,
	Dominique Martinet <asmadeus@codewreck.org>,
	David Miller <davem@davemloft.net>,
	Eric Van Hensbergen <ericvh@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Latchesar Ionkov <lucho@ionkov.net>,
	netdev <netdev@vger.kernel.org>,
	syzkaller-bugs <syzkaller-bugs@googlegroups.com>,
	v9fs-developer@lists.sourceforge.net,
	Linux-MM <linux-mm@kvack.org>, Pekka Enberg <penberg@kernel.org>,
	David Rientjes <rientjes@google.com>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: BUG: unable to handle kernel NULL pointer dereference in setup_kmem_cache_node
Date: Wed, 2 Jan 2019 15:51:12 +0000	[thread overview]
Message-ID: <010001680f42f192-82b4e12e-1565-4ee0-ae1f-1e98974906aa-000000@email.amazonses.com> (raw)
In-Reply-To: <CACT4Y+ZECp8Ymq=0QUNfwmfpQvWkBpoMgyUCuz0M=peehEeCHw@mail.gmail.com>

On Wed, 2 Jan 2019, Dmitry Vyukov wrote:

> Am I missing something or __alloc_alien_cache misses check for
> kmalloc_node result?
>
> static struct alien_cache *__alloc_alien_cache(int node, int entries,
>                                                 int batch, gfp_t gfp)
> {
>         size_t memsize = sizeof(void *) * entries + sizeof(struct alien_cache);
>         struct alien_cache *alc = NULL;
>
>         alc = kmalloc_node(memsize, gfp, node);
>         init_arraycache(&alc->ac, entries, batch);
>         spin_lock_init(&alc->lock);
>         return alc;
> }
>


True _alloc_alien_cache() needs to check for NULL


From: Christoph Lameter <cl@linux.com>
Subject: slab: Alien caches must not be initialized if the allocation of the alien cache failed

Callers of __alloc_alien() check for NULL.
We must do the same check in __alloc_alien_cache to avoid NULL pointer dereferences
on allocation failures.

Signed-off-by: Christoph Lameter <cl@linux.com>


Index: linux/mm/slab.c
===================================================================
--- linux.orig/mm/slab.c
+++ linux/mm/slab.c
@@ -666,8 +666,10 @@ static struct alien_cache *__alloc_alien
 	struct alien_cache *alc = NULL;

 	alc = kmalloc_node(memsize, gfp, node);
-	init_arraycache(&alc->ac, entries, batch);
-	spin_lock_init(&alc->lock);
+	if (alc) {
+		init_arraycache(&alc->ac, entries, batch);
+		spin_lock_init(&alc->lock);
+	}
 	return alc;
 }

  parent reply	other threads:[~2019-01-02 15:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <0000000000000f35c6057e780d36@google.com>
2019-01-02 11:54 ` Dmitry Vyukov
2019-01-02 11:54   ` Dmitry Vyukov
2019-01-02 15:51   ` Christopher Lameter [this message]
2019-01-02 15:51     ` Christopher Lameter
2019-01-02 16:01     ` Dmitry Vyukov
2019-01-02 16:01       ` Dmitry Vyukov

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=010001680f42f192-82b4e12e-1565-4ee0-ae1f-1e98974906aa-000000@email.amazonses.com \
    --to=cl@linux.com \
    --cc=akpm@linux-foundation.org \
    --cc=asmadeus@codewreck.org \
    --cc=davem@davemloft.net \
    --cc=dvyukov@google.com \
    --cc=ericvh@gmail.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lucho@ionkov.net \
    --cc=netdev@vger.kernel.org \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    --cc=syzbot+d6ed4ec679652b4fd4e4@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=v9fs-developer@lists.sourceforge.net \
    /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