1. 25 Jul, 2018 2 commits
    • Mark Rutland's avatar
      locking/atomics: Simplify cmpxchg() instrumentation · df79ed2c
      Mark Rutland authored
      Currently we define some fairly verbose wrappers for the cmpxchg()
      family so that we can pass a pointer and size into kasan_check_write().
      
      The wrappers duplicate the size-switching logic necessary in arch code,
      and only work for scalar types. On some architectures, (cmp)xchg are
      used on non-scalar types, and thus the instrumented wrappers need to be
      able to handle this.
      
      We could take the type-punning logic from {READ,WRITE}_ONCE(), but this
      makes the wrappers even more verbose, and requires several local
      variables in the macros.
      
      Instead, let's simplify the wrappers into simple macros which:
      
      * snapshot the pointer into a single local variable, called __ai_ptr to
        avoid conflicts with variables in the scope of the caller.
      
      * call kasan_check_write() on __ai_ptr.
      
      * invoke the relevant arch_*() function, passing the original arguments,
        bar __ai_ptr being substituted for ptr.
      
      There should be no functional change as a result of this patch.
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarWill Deacon <will.deacon@arm.com>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: andy.shevchenko@gmail.com
      Cc: arnd@arndb.de
      Cc: aryabinin@virtuozzo.com
      Cc: catalin.marinas@arm.com
      Cc: glider@google.com
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: parri.andrea@gmail.com
      Cc: peter@hurleysoftware.com
      Link: http://lkml.kernel.org/r/20180716113017.3909-4-mark.rutland@arm.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      df79ed2c
    • Mark Rutland's avatar
      locking/atomics/x86: Reduce arch_cmpxchg64*() instrumentation · 00d5551c
      Mark Rutland authored
      Currently x86's arch_cmpxchg64() and arch_cmpxchg64_local() are
      instrumented twice, as they call into instrumented atomics rather than
      their arch_ equivalents.
      
      A call to cmpxchg64() results in:
      
        cmpxchg64()
          kasan_check_write()
          arch_cmpxchg64()
            cmpxchg()
              kasan_check_write()
              arch_cmpxchg()
      
      Let's fix this up and call the arch_ equivalents, resulting in:
      
        cmpxchg64()
          kasan_check_write()
          arch_cmpxchg64()
            arch_cmpxchg()
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Acked-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarWill Deacon <will.deacon@arm.com>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: andy.shevchenko@gmail.com
      Cc: arnd@arndb.de
      Cc: aryabinin@virtuozzo.com
      Cc: catalin.marinas@arm.com
      Cc: glider@google.com
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: parri.andrea@gmail.com
      Cc: peter@hurleysoftware.com
      Link: http://lkml.kernel.org/r/20180716113017.3909-3-mark.rutland@arm.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      00d5551c
  2. 17 Jul, 2018 15 commits
  3. 15 Jul, 2018 2 commits
  4. 14 Jul, 2018 19 commits
  5. 13 Jul, 2018 2 commits