From: Dmitry Vyukov <dvyukov@google.com>
To: Christopher Lameter <cl@linux.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 17:01:20 +0100 [thread overview]
Message-ID: <CACT4Y+Z8M+ODKobZYzWBbPv_y_Y2xNBfuUuX7iVceeLap2Yq3g@mail.gmail.com> (raw)
Message-ID: <20190102160120.6eQxKX53rdKsVvq6onW41qaNyxAzL-bOQw0bO6WwxiA@z> (raw)
In-Reply-To: <010001680f42f192-82b4e12e-1565-4ee0-ae1f-1e98974906aa-000000@email.amazonses.com>
On Wed, Jan 2, 2019 at 4:51 PM Christopher Lameter <cl@linux.com> wrote:
>
> 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>
Please add:
Reported-by: syzbot+d6ed4ec679652b4fd4e4@syzkaller.appspotmail.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;
> }
>
next prev parent reply other threads:[~2019-01-02 16:01 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
2019-01-02 15:51 ` Christopher Lameter
2019-01-02 16:01 ` Dmitry Vyukov [this message]
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=CACT4Y+Z8M+ODKobZYzWBbPv_y_Y2xNBfuUuX7iVceeLap2Yq3g@mail.gmail.com \
--to=dvyukov@google.com \
--cc=akpm@linux-foundation.org \
--cc=asmadeus@codewreck.org \
--cc=cl@linux.com \
--cc=davem@davemloft.net \
--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