From: Dmitry Vyukov <dvyukov@google.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: syzkaller <syzkaller@googlegroups.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Kostya Serebryany <kcc@google.com>,
Alexander Potapenko <glider@google.com>,
Eric Dumazet <edumazet@google.com>,
Sasha Levin <sasha.levin@oracle.com>
Subject: Re: use-after-free in __perf_install_in_context
Date: Tue, 8 Dec 2015 19:35:20 +0100 [thread overview]
Message-ID: <CACT4Y+Y-wBH+xfei_q-6FcEoShM8sX4eX3bQyfEppWy522RiYw@mail.gmail.com> (raw)
In-Reply-To: <20151208180528.GA77166@ast-mbp.thefacebook.com>
On Tue, Dec 8, 2015 at 7:05 PM, Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
> On Tue, Dec 08, 2015 at 06:56:23PM +0100, Dmitry Vyukov wrote:
>> On Tue, Dec 8, 2015 at 6:54 PM, Alexei Starovoitov
>> <alexei.starovoitov@gmail.com> wrote:
>> > On Tue, Dec 08, 2015 at 05:12:04PM +0100, Dmitry Vyukov wrote:
>> >> On Tue, Dec 8, 2015 at 4:24 AM, Alexei Starovoitov
>> >> <alexei.starovoitov@gmail.com> wrote:
>> >> > On Mon, Dec 07, 2015 at 05:09:21PM +0100, Dmitry Vyukov wrote:
>> >> >> > So it would be _awesome_ if we could somehow extend this callchain to
>> >> >> > include the site that calls call_rcu().
>> >> >>
>> >> >> We have a patch for KASAN in works that adds so-called stack depot
>> >> >> which allows to map a stack trace onto uint32 id. Then we can plumb
>> >> >
>> >> > I was hacking something similar to categorize stack traces with u32 id.
>> >> > How are you planning to limit the number of such stack traces ?
>> >> > and what is the interface for user space to get stack trace from an id?
>> >>
>> >>
>> >> We don't limit number of stack traces. Kernel does not seem to use
>> >> data-driven recursion extensively, so there is limited number of
>> >> stacks. Though, probably we will need to strip non-interrupt part for
>> >> interrupt stacks, otherwise that can produce unbounded number of
>> >> different stacks.
>> >> There is no interface for user-space, it is used only inside of kernel
>> >> to save stacks for memory blocks (rcu callbacks, thread pool items in
>> >> the future).
>> >> The design is based on what we successfully and extensively use in
>> >> user-space sanitizers for years. Current code is here:
>> >> https://github.com/ramosian-glider/kasan/commit/fb0eefd212366401ed5ad244233ef379a27bfb46
>> >
>> > why did you pick approach to never free accumulated stacks?
>> > That limits usability a lot, since once kasan starts using it only
>> > reboot will free the memory. ouch.
>> > what worked for user space doesn't work for kernel.
>>
>>
>> Freeing and reusing will slow down and complicate code significantly.
>> And it is not yet proved to be necessary.
>
> It's a joke, right? allocating kernel pages without ability to free?!
The plan is to smash kernel much earlier than it will run out of memory.
I think this scheme will work pretty well.
I've counted 34403 calls to
kmalloc/kfree/kmem_cache_alloc/kmem_cache_free in kernel. Multiply
this by 2 to account for different stacks leading to the same
malloc/free and assuming that we store 16-byte header and 20 4-byte
frames, this gives us about 6MB. I can live with that. I can live with
60MB as well.
next prev parent reply other threads:[~2015-12-08 18:35 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-04 20:04 use-after-free in __perf_install_in_context Dmitry Vyukov
2015-12-04 20:32 ` Alexei Starovoitov
2015-12-04 21:00 ` Dmitry Vyukov
2015-12-07 11:04 ` Dmitry Vyukov
2015-12-07 11:06 ` Dmitry Vyukov
2015-12-07 11:24 ` Dmitry Vyukov
2015-12-07 15:36 ` Peter Zijlstra
2015-12-07 16:09 ` Dmitry Vyukov
2015-12-08 3:24 ` Alexei Starovoitov
2015-12-08 16:12 ` Dmitry Vyukov
2015-12-08 17:54 ` Alexei Starovoitov
2015-12-08 17:56 ` Dmitry Vyukov
2015-12-08 18:05 ` Alexei Starovoitov
2015-12-08 18:35 ` Dmitry Vyukov [this message]
2015-12-08 19:56 ` Alexei Starovoitov
2015-12-09 9:17 ` Dmitry Vyukov
2015-12-10 3:54 ` Alexei Starovoitov
2015-12-10 9:02 ` Peter Zijlstra
2015-12-10 17:03 ` Alexei Starovoitov
2015-12-11 8:14 ` Ingo Molnar
2015-12-15 13:11 ` Dmitry Vyukov
2015-12-08 16:44 ` Peter Zijlstra
2015-12-08 19:14 ` Dmitry Vyukov
2015-12-10 19:57 ` Peter Zijlstra
2015-12-15 13:09 ` Dmitry Vyukov
2015-12-17 14:06 ` Peter Zijlstra
2015-12-17 14:08 ` Dmitry Vyukov
2015-12-17 14:26 ` Peter Zijlstra
2015-12-17 14:28 ` Peter Zijlstra
2015-12-17 14:35 ` Dmitry Vyukov
2015-12-17 14:43 ` Peter Zijlstra
2015-12-31 17:15 ` Dmitry Vyukov
2016-01-05 12:17 ` Peter Zijlstra
2016-01-08 8:40 ` Dmitry Vyukov
2016-01-08 10:28 ` Dmitry Vyukov
2016-01-06 18:46 ` [tip:perf/core] perf: Fix race in perf_event_exec() tip-bot for Peter Zijlstra
2016-01-06 18:56 ` Eric Dumazet
2016-01-07 13:40 ` Peter Zijlstra
2016-01-07 16:26 ` Paul E. McKenney
2016-01-07 16:36 ` Eric Dumazet
2016-01-07 16:46 ` Paul E. McKenney
2015-12-08 16:22 ` use-after-free in __perf_install_in_context Peter Zijlstra
2015-12-08 18:57 ` Ingo Molnar
2015-12-09 9:05 ` Peter Zijlstra
2015-12-08 16:27 ` Peter Zijlstra
2015-12-08 16:50 ` 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+Y-wBH+xfei_q-6FcEoShM8sX4eX3bQyfEppWy522RiYw@mail.gmail.com \
--to=dvyukov@google.com \
--cc=acme@kernel.org \
--cc=alexei.starovoitov@gmail.com \
--cc=edumazet@google.com \
--cc=glider@google.com \
--cc=kcc@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=sasha.levin@oracle.com \
--cc=syzkaller@googlegroups.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;
as well as URLs for NNTP newsgroup(s).