lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAPAsAGx58NuvRB7=qeXr27VFE8PoabLxvNGVGP66MV1WkhDA+g@mail.gmail.com>
Date:	Mon, 14 Mar 2016 19:56:19 +0300
From:	Andrey Ryabinin <ryabinin.a.a@...il.com>
To:	Alexander Potapenko <glider@...gle.com>
Cc:	Andrey Konovalov <adech.fo@...il.com>,
	Christoph Lameter <cl@...ux.com>,
	Dmitry Vyukov <dvyukov@...gle.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Steven Rostedt <rostedt@...dmis.org>,
	Joonsoo Kim <iamjoonsoo.kim@....com>,
	JoonSoo Kim <js1304@...il.com>,
	Kostya Serebryany <kcc@...gle.com>,
	kasan-dev <kasan-dev@...glegroups.com>,
	LKML <linux-kernel@...r.kernel.org>,
	"linux-mm@...ck.org" <linux-mm@...ck.org>
Subject: Re: [PATCH v7 5/7] mm, kasan: Stackdepot implementation. Enable
 stackdepot for SLAB

2016-03-14 13:43 GMT+03:00 Alexander Potapenko <glider@...gle.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);
> +               }
> +       }
> +

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ