• Daniel Axtens's avatar
    kasan: allow an architecture to disable inline instrumentation · 158f2552
    Daniel Axtens authored
    Patch series "KASAN core changes for ppc64 radix KASAN", v16.
    
    Building on the work of Christophe, Aneesh and Balbir, I've ported KASAN
    to 64-bit Book3S kernels running on the Radix MMU.  I've been trying this
    for a while, but we keep having collisions between the kasan code in the
    mm tree and the code I want to put in to the ppc tree.
    
    This series just contains the kasan core changes that we need.  There
    should be no noticeable changes to other platforms.
    
    This patch (of 4):
    
    For annoying architectural reasons, it's very difficult to support inline
    instrumentation on powerpc64.*
    
    Add a Kconfig flag to allow an arch to disable inline.  (It's a bit
    annoying to be 'backwards', but I'm not aware of any way to have an arch
    force a symbol to be 'n', rather than 'y'.)
    
    We also disable stack instrumentation in this case as it does things that
    are functionally equivalent to inline instrumentation, namely adding code
    that touches the shadow directly without going through a C helper.
    
    * on ppc64 atm, the shadow lives in virtual memory and isn't accessible in
    real mode.  However, before we turn on virtual memory, we parse the device
    tree to determine which platform and MMU we're running under.  That calls
    generic DT code, which is instrumented.  Inline instrumentation in DT
    would unconditionally attempt to touch the shadow region, which we won't
    have set up yet, and would crash.  We can make outline mode wait for the
    arch to be ready, but we can't change what the compiler inserts for inline
    mode.
    
    Link: https://lkml.kernel.org/r/20210624034050.511391-1-dja@axtens.net
    Link: https://lkml.kernel.org/r/20210624034050.511391-2-dja@axtens.netSigned-off-by: default avatarDaniel Axtens <dja@axtens.net>
    Reviewed-by: default avatarMarco Elver <elver@google.com>
    Reviewed-by: default avatarAndrey Konovalov <andreyknvl@gmail.com>
    Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
    Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
    Cc: Balbir Singh <bsingharora@gmail.com>
    Cc: Alexander Potapenko <glider@google.com>
    Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
    Cc: Dmitry Vyukov <dvyukov@google.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    158f2552
Kconfig.kasan 7.15 KB