Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1517920

Re: KASAN & the vmalloc area

From Mark Rutland <mark.rutland@arm.com>
Newsgroups linux.kernel
Subject Re: KASAN & the vmalloc area
Date 2016-11-09 12:00 +0100
Message-ID <sByLM-6cP-17@gated-at.bofh.it> (permalink)
References <sBjWq-53v-47@gated-at.bofh.it> <sBmUi-74r-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, Nov 08, 2016 at 02:09:27PM -0800, Dmitry Vyukov wrote:
> On Tue, Nov 8, 2016 at 11:03 AM, Mark Rutland <mark.rutland@arm.com> wrote:
> > When KASAN is selected, we allocate shadow for the whole vmalloc area,
> > using common zero pte, pmd, pud tables. Walking over these in the ptdump
> > code takes a *very* long time (I've seen up to 15 minutes with
> > KASAN_OUTLINE enabled). For DEBUG_WX [3], this means boot hangs for that
> > long, too.

[...]
 
> I've seen the same iteration slowness problem on x86 with
> CONFIG_DEBUG_RODATA which walks all pages. The is about 1 minute, but
> it is enough to trigger rcu stall warning.

Interesting; do you know where that happens? I can't spot any obvious
case where we'd have to walk all the page tables for DEBUG_RODATA.

> The zero pud and vmalloc-ed stacks looks like different problems.
> To overcome the slowness we could map zero shadow for vmalloc area lazily.
> However for vmalloc-ed stacks we need to map actual memory, because
> stack instrumentation will read/write into the shadow. 

Sure. The point I was trying to make is that there' be fewer page tables
to walk (unless the vmalloc area was exhausted), assuming we also lazily
mapped the common zero shadow for the vmalloc area.

> One downside here is that vmalloc shadow can be as large as 1:1 (if we
> allocate 1 page in vmalloc area we need to allocate 1 page for
> shadow).

I thought per prior discussion we'd only need to allocate new pages for
the stacks in the vmalloc region, and we could re-use the zero pages?

... or are you trying to quantify the cost of the page tables?

> Re slowness: could we just skip the KASAN zero puds (the top level)
> while walking? Can they be interesting for anybody?

They're interesting for the ptdump case (which allows privileged users
to dump the tables via /sys/kernel/debug/kernel_page_tables). I've seen
25+ minute hangs there.

> We can just pretend that they are not there. Looks like a trivial
> solution for the problem at hand.

For the boot time hang it's option. Though I'd prefer that the sanity
checks applied to all of tables, shadow regions included.

Thanks,
Mark.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

KASAN & the vmalloc area Mark Rutland <mark.rutland@arm.com> - 2016-11-08 20:10 +0100
  Re: KASAN & the vmalloc area Dmitry Vyukov <dvyukov@google.com> - 2016-11-08 23:20 +0100
    Re: KASAN & the vmalloc area Mark Rutland <mark.rutland@arm.com> - 2016-11-09 12:00 +0100
      Re: KASAN & the vmalloc area Dmitry Vyukov <dvyukov@google.com> - 2016-11-09 19:20 +0100
        Re: KASAN & the vmalloc area Mark Rutland <mark.rutland@arm.com> - 2016-11-09 19:40 +0100
          Re: KASAN & the vmalloc area Dmitry Vyukov <dvyukov@google.com> - 2016-11-09 19:50 +0100
  Re: KASAN & the vmalloc area Dmitry Vyukov <dvyukov@google.com> - 2016-11-09 19:30 +0100

csiph-web