• Marco Elver's avatar
    kcsan: Support WEAK_MEMORY with Clang where no objtool support exists · bd3d5bd1
    Marco Elver authored
    Clang and GCC behave a little differently when it comes to the
    __no_sanitize_thread attribute, which has valid reasons, and depending
    on context either one could be right.
    
    Traditionally, user space ThreadSanitizer [1] still expects instrumented
    builtin atomics (to avoid false positives) and __tsan_func_{entry,exit}
    (to generate meaningful stack traces), even if the function has the
    attribute no_sanitize("thread").
    
    [1] https://clang.llvm.org/docs/ThreadSanitizer.html#attribute-no-sanitize-thread
    
    GCC doesn't follow the same policy (for better or worse), and removes
    all kinds of instrumentation if no_sanitize is added. Arguably, since
    this may be a problem for user space ThreadSanitizer, we expect this may
    change in future.
    
    Since KCSAN != ThreadSanitizer, the likelihood of false positives even
    without barrier instrumentation everywhere, is much lower by design.
    
    At least for Clang, however, to fully remove all sanitizer
    instrumentation, we must add the disable_sanitizer_instrumentation
    attribute, which is available since Clang 14.0.
    Signed-off-by: default avatarMarco Elver <elver@google.com>
    Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
    bd3d5bd1
Kconfig.kcsan 10.3 KB