From: Andrey Ryabinin <ryabinin.a.a@gmail.com>
To: Alexander Potapenko <glider@google.com>
Cc: Andrey Konovalov <adech.fo@gmail.com>,
Christoph Lameter <cl@linux.com>,
Dmitry Vyukov <dvyukov@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Steven Rostedt <rostedt@goodmis.org>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
JoonSoo Kim <js1304@gmail.com>,
Kostya Serebryany <kcc@google.com>,
kasan-dev <kasan-dev@googlegroups.com>,
LKML <linux-kernel@vger.kernel.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: [PATCH v7 5/7] mm, kasan: Stackdepot implementation. Enable stackdepot for SLAB
Date: Mon, 14 Mar 2016 19:56:19 +0300 [thread overview]
Message-ID: <CAPAsAGx58NuvRB7=qeXr27VFE8PoabLxvNGVGP66MV1WkhDA+g@mail.gmail.com> (raw)
In-Reply-To: <4f6880ee0c1545b3ae9c25cfe86a879d724c4e7b.1457949315.git.glider@google.com>
2016-03-14 13:43 GMT+03:00 Alexander Potapenko <glider@google.com>:
> +
> + rec = this_cpu_ptr(&depot_recursion);
> + /* Don't store the stack if we've been called recursively. */
> + if (unlikely(*rec))
> + goto fast_exit;
> + *rec = true;
This just can't work. As long as preemption enabled, task could
migrate on another cpu anytime.
You could use per-task flag, although it's possible to miss some
in-irq stacktraces:
depot_save_stack()
if (current->stackdeport_recursion)
goto fast_exit;
current->stackdepot_recursion++
<IRQ>
....
depot_save_stack()
if (current->stackdeport_recursion)
goto fast_exit;
> + if (unlikely(!smp_load_acquire(&next_slab_inited))) {
> + /* Zero out zone modifiers, as we don't have specific zone
> + * requirements. Keep the flags related to allocation in atomic
> + * contexts and I/O.
> + */
> + alloc_flags &= ~GFP_ZONEMASK;
> + alloc_flags &= (GFP_ATOMIC | GFP_KERNEL);
> + /* When possible, allocate using vmalloc() to reduce physical
> + * address space fragmentation. vmalloc() doesn't work if
> + * kmalloc caches haven't been initialized or if it's being
> + * called from an interrupt handler.
> + */
> + if (kmalloc_caches[KMALLOC_SHIFT_HIGH] && !in_interrupt()) {
This is clearly a wrong way to check whether is slab available or not.
Besides you need to check
vmalloc() for availability, not slab.
Given that STAC_ALLOC_ORDER is 2 now, I think it should be fine to use
alloc_pages() all the time.
Or fix condition, up to you.
> + prealloc = __vmalloc(
> + STACK_ALLOC_SIZE, alloc_flags, PAGE_KERNEL);
> + } else {
> + page = alloc_pages(alloc_flags, STACK_ALLOC_ORDER);
> + if (page)
> + prealloc = page_address(page);
> + }
> + }
> +
--
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:[~2016-03-14 16:56 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-14 10:43 [PATCH v7 0/7] SLAB support for KASAN Alexander Potapenko
2016-03-14 10:43 ` [PATCH v7 1/7] kasan: Modify kmalloc_large_oob_right(), add kmalloc_pagealloc_oob_right() Alexander Potapenko
2016-03-14 10:43 ` [PATCH v7 2/7] mm, kasan: SLAB support Alexander Potapenko
2016-03-14 10:43 ` [PATCH v7 3/7] mm, kasan: Added GFP flags to KASAN API Alexander Potapenko
2016-03-14 10:43 ` [PATCH v7 4/7] arch, ftrace: For KASAN put hard/soft IRQ entries into separate sections Alexander Potapenko
2016-03-14 10:43 ` [PATCH v7 5/7] mm, kasan: Stackdepot implementation. Enable stackdepot for SLAB Alexander Potapenko
2016-03-14 16:56 ` Andrey Ryabinin [this message]
2016-03-15 9:27 ` Alexander Potapenko
2016-03-15 12:22 ` Andrey Ryabinin
2016-03-18 15:12 ` Alexander Potapenko
2016-04-11 7:44 ` Joonsoo Kim
2016-04-11 14:39 ` Alexander Potapenko
2016-04-11 14:51 ` Alexander Potapenko
2016-04-12 4:51 ` Joonsoo Kim
2016-03-14 10:43 ` [PATCH v7 6/7] kasan: Test fix: Warn if the UAF could not be detected in kmalloc_uaf2 Alexander Potapenko
2016-03-14 10:43 ` [PATCH v7 7/7] mm: kasan: Initial memory quarantine implementation Alexander Potapenko
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='CAPAsAGx58NuvRB7=qeXr27VFE8PoabLxvNGVGP66MV1WkhDA+g@mail.gmail.com' \
--to=ryabinin.a.a@gmail.com \
--cc=adech.fo@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=js1304@gmail.com \
--cc=kasan-dev@googlegroups.com \
--cc=kcc@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rostedt@goodmis.org \
/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