linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Potapenko <glider@google.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Andrey Konovalov <adech.fo@gmail.com>,
	Christoph Lameter <cl@linux.com>,
	Dmitriy Vyukov <dvyukov@google.com>,
	Andrey Ryabinin <ryabinin.a.a@gmail.com>,
	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 Memory Management List <linux-mm@kvack.org>
Subject: Re: [PATCH v5 5/7] mm, kasan: Stackdepot implementation. Enable stackdepot for SLAB
Date: Thu, 10 Mar 2016 15:00:17 +0100	[thread overview]
Message-ID: <CAG_fn=VJU4p4Xk0vggWpwSrFnZ7iNTWn8LaY8sbBoxTMT7YdQw@mail.gmail.com> (raw)
In-Reply-To: <20160309120912.83a82c79fd2bf6d21ab2c16a@linux-foundation.org>

On Wed, Mar 9, 2016 at 9:09 PM, Andrew Morton <akpm@linux-foundation.org> wrote:
> On Wed,  9 Mar 2016 12:05:46 +0100 Alexander Potapenko <glider@google.com> wrote:
>
>> Implement the stack depot and provide CONFIG_STACKDEPOT.
>> Stack depot will allow KASAN store allocation/deallocation stack traces
>> for memory chunks. The stack traces are stored in a hash table and
>> referenced by handles which reside in the kasan_alloc_meta and
>> kasan_free_meta structures in the allocated memory chunks.
>>
>> IRQ stack traces are cut below the IRQ entry point to avoid unnecessary
>> duplication.
>>
>> Right now stackdepot support is only enabled in SLAB allocator.
>> Once KASAN features in SLAB are on par with those in SLUB we can switch
>> SLUB to stackdepot as well, thus removing the dependency on SLUB stack
>> bookkeeping, which wastes a lot of memory.
>>
>> This patch is based on the "mm: kasan: stack depots" patch originally
>> prepared by Dmitry Chernenkov.
>>
>
> Have you identified other potential clients for the stackdepot code?
Joonsoo Kim said he is planning to use stackdepot for the page owner.
>> --- /dev/null
>> +++ b/include/linux/stackdepot.h
>> @@ -0,0 +1,32 @@
>> +/*
>> + * A generic stack depot implementation
>> + *
>> + * Author: Alexander Potapenko <glider@google.com>
>> + * Copyright (C) 2016 Google, Inc.
>> + *
>> + * Based on code by Dmitry Chernenkov.
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License as published by
>> + * the Free Software Foundation; either version 2 of the License, or
>> + * (at your option) any later version.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + *
>> + */
>> +
>> +#ifndef _LINUX_STACKDEPOT_H
>> +#define _LINUX_STACKDEPOT_H
>> +
>> +typedef u32 depot_stack_handle;
>
> I'll rename this to depot_stack_handle_t, which is a pretty strong
> kernel convention.
Ok, thank you!
>> +struct stack_trace;
>> +
>> +depot_stack_handle depot_save_stack(struct stack_trace *trace, gfp_t flags);
>> +
>> +void depot_fetch_stack(depot_stack_handle handle, struct stack_trace *trace);
>> +
>> +#endif
>> diff --git a/lib/Kconfig b/lib/Kconfig
>> index ee38a3f..8a60a53 100644
>> --- a/lib/Kconfig
>> +++ b/lib/Kconfig
>> @@ -543,4 +543,7 @@ config ARCH_HAS_PMEM_API
>>  config ARCH_HAS_MMIO_FLUSH
>>       bool
>>
>> +config STACKDEPOT
>> +  bool
>> +
>>  endmenu
>> diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan
>> index 0e4d2b3..468316d 100644
>> --- a/lib/Kconfig.kasan
>> +++ b/lib/Kconfig.kasan
>> @@ -7,6 +7,7 @@ config KASAN
>>       bool "KASan: runtime memory debugger"
>>       depends on SLUB_DEBUG || (SLAB && !DEBUG_SLAB)
>>       select CONSTRUCTORS
>> +  select STACKDEPOT if SLAB
>>       help
>>         Enables kernel address sanitizer - runtime memory debugger,
>>         designed to find out-of-bounds accesses and use-after-free bugs.
>
> Something weird happened to the Kconfig whitespace.  I'll fix that.
Thanks!
>



-- 
Alexander Potapenko
Software Engineer

Google Germany GmbH
Erika-Mann-Straße, 33
80636 München

Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg

--
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>

  reply	other threads:[~2016-03-10 14:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-09 11:05 [PATCH v4 0/7] SLAB support for KASAN Alexander Potapenko
2016-03-09 11:05 ` [PATCH v5 1/7] kasan: Modify kmalloc_large_oob_right(), add kmalloc_pagealloc_oob_right() Alexander Potapenko
2016-03-09 11:05 ` [PATCH v5 2/7] mm, kasan: SLAB support Alexander Potapenko
2016-03-11 11:47   ` Andrey Ryabinin
2016-03-11 13:05     ` Alexander Potapenko
2016-03-11 13:57       ` Andrey Ryabinin
2016-03-09 11:05 ` [PATCH v5 3/7] mm, kasan: Added GFP flags to KASAN API Alexander Potapenko
2016-03-09 11:05 ` [PATCH v5 4/7] arch, ftrace: For KASAN put hard/soft IRQ entries into separate sections Alexander Potapenko
2016-03-09 11:05 ` [PATCH v5 5/7] mm, kasan: Stackdepot implementation. Enable stackdepot for SLAB Alexander Potapenko
2016-03-09 20:09   ` Andrew Morton
2016-03-10 14:00     ` Alexander Potapenko [this message]
2016-03-09 11:05 ` [PATCH v5 6/7] kasan: Test fix: Warn if the UAF could not be detected in kmalloc_uaf2 Alexander Potapenko
2016-03-09 11:05 ` [PATCH v5 7/7] mm: kasan: Initial memory quarantine implementation Alexander Potapenko
2016-03-09 20:21   ` Andrew Morton
2016-03-10 13:50     ` Alexander Potapenko
2016-03-10 20:14       ` Andrew Morton
2016-03-11 10:05         ` Alexander Potapenko
2016-03-11 17:12       ` Alexander Potapenko
2016-03-09 11:12 ` [PATCH v4 0/7] SLAB support for KASAN Alexander Potapenko
2016-03-09 20:23 ` [PATCH v5 " Andrew Morton
2016-03-10 17:01   ` Andrey Ryabinin

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='CAG_fn=VJU4p4Xk0vggWpwSrFnZ7iNTWn8LaY8sbBoxTMT7YdQw@mail.gmail.com' \
    --to=glider@google.com \
    --cc=adech.fo@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=dvyukov@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 \
    --cc=ryabinin.a.a@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