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


Groups > linux.kernel > #1593326

Re: [PATCH] x86, kasan: add KASAN checks to atomic operations

From Peter Zijlstra <peterz@infradead.org>
Newsgroups linux.kernel
Subject Re: [PATCH] x86, kasan: add KASAN checks to atomic operations
Date 2017-03-06 14:50 +0100
Message-ID <ti1br-uP-13@gated-at.bofh.it> (permalink)
References <ti0p3-8iJ-9@gated-at.bofh.it> <ti0p4-8iJ-33@gated-at.bofh.it> <ti0S6-lW-25@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Mar 06, 2017 at 01:58:51PM +0100, Peter Zijlstra wrote:
> On Mon, Mar 06, 2017 at 01:50:47PM +0100, Dmitry Vyukov wrote:
> > On Mon, Mar 6, 2017 at 1:42 PM, Dmitry Vyukov <dvyukov@google.com> wrote:
> > > KASAN uses compiler instrumentation to intercept all memory accesses.
> > > But it does not see memory accesses done in assembly code.
> > > One notable user of assembly code is atomic operations. Frequently,
> > > for example, an atomic reference decrement is the last access to an
> > > object and a good candidate for a racy use-after-free.
> > >
> > > Add manual KASAN checks to atomic operations.
> > > Note: we need checks only before asm blocks and don't need them
> > > in atomic functions composed of other atomic functions
> > > (e.g. load-cmpxchg loops).
> > 
> > Peter, also pointed me at arch/x86/include/asm/bitops.h. Will add them in v2.
> > 
> 
> > >  static __always_inline void atomic_add(int i, atomic_t *v)
> > >  {
> > > +       kasan_check_write(v, sizeof(*v));
> > >         asm volatile(LOCK_PREFIX "addl %1,%0"
> > >                      : "+m" (v->counter)
> > >                      : "ir" (i));
> 
> 
> So the problem is doing load/stores from asm bits, and GCC
> (traditionally) doesn't try and interpret APP asm bits.
> 
> However, could we not write a GCC plugin that does exactly that?
> Something that interprets the APP asm bits and generates these KASAN
> bits that go with it?

Another suspect is the per-cpu stuff, that's all asm foo as well.

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


Thread

[PATCH] x86, kasan: add KASAN checks to atomic operations Dmitry Vyukov <dvyukov@google.com> - 2017-03-06 14:00 +0100
  Re: [PATCH] x86, kasan: add KASAN checks to atomic operations Dmitry Vyukov <dvyukov@google.com> - 2017-03-06 14:00 +0100
    Re: [PATCH] x86, kasan: add KASAN checks to atomic operations Peter Zijlstra <peterz@infradead.org> - 2017-03-06 14:30 +0100
      Re: [PATCH] x86, kasan: add KASAN checks to atomic operations Peter Zijlstra <peterz@infradead.org> - 2017-03-06 14:50 +0100
        Re: [PATCH] x86, kasan: add KASAN checks to atomic operations Dmitry Vyukov <dvyukov@google.com> - 2017-03-06 15:30 +0100
          Re: [PATCH] x86, kasan: add KASAN checks to atomic operations Peter Zijlstra <peterz@infradead.org> - 2017-03-06 16:40 +0100
          Re: [PATCH] x86, kasan: add KASAN checks to atomic operations Peter Zijlstra <peterz@infradead.org> - 2017-03-06 16:50 +0100
            Re: [PATCH] x86, kasan: add KASAN checks to atomic operations Mark Rutland <mark.rutland@arm.com> - 2017-03-06 17:20 +0100
          Re: [PATCH] x86, kasan: add KASAN checks to atomic operations Mark Rutland <mark.rutland@arm.com> - 2017-03-06 17:40 +0100
            Re: [PATCH] x86, kasan: add KASAN checks to atomic operations Dmitry Vyukov <dvyukov@google.com> - 2017-03-06 17:40 +0100
              Re: [PATCH] x86, kasan: add KASAN checks to atomic operations Mark Rutland <mark.rutland@arm.com> - 2017-03-06 18:30 +0100
            Re: [PATCH] x86, kasan: add KASAN checks to atomic operations Peter Zijlstra <peterz@infradead.org> - 2017-03-06 22:10 +0100
              Re: [PATCH] x86, kasan: add KASAN checks to atomic operations Dmitry Vyukov <dvyukov@google.com> - 2017-03-08 16:30 +0100
                Re: [PATCH] x86, kasan: add KASAN checks to atomic operations Dmitry Vyukov <dvyukov@google.com> - 2017-03-08 16:50 +0100
                Re: [PATCH] x86, kasan: add KASAN checks to atomic operations Mark Rutland <mark.rutland@arm.com> - 2017-03-08 17:00 +0100
                Re: [PATCH] x86, kasan: add KASAN checks to atomic operations Mark Rutland <mark.rutland@arm.com> - 2017-03-08 16:50 +0100
              Re: [PATCH] x86, kasan: add KASAN checks to atomic operations Mark Rutland <mark.rutland@arm.com> - 2017-03-08 16:40 +0100
                Re: [PATCH] x86, kasan: add KASAN checks to atomic operations Will Deacon <will.deacon@arm.com> - 2017-03-08 19:50 +0100
              Re: [PATCH] x86, kasan: add KASAN checks to atomic operations Dmitry Vyukov <dvyukov@google.com> - 2017-03-08 17:30 +0100

csiph-web