does software KASAN not instrument READ_ONCE() on arm64 with LTO?

From: Jann Horn
Date: Wed Mar 26 2025 - 19:10:27 EST


Hi!

I just realized - arm64 redefines __READ_ONCE() to use inline assembly
instead of a volatile load, and ASAN is designed to not instrument asm
statement operands (not even memory operands).
(I think I may have a years-old LLVM patch somewhere that changes
that, but I vaguely recall being told once that that's an intentional
design decision. I might be misremembering that though...)

So because __READ_ONCE() does not call anything like
instrument_read(), I think instrumentation-based KASAN in LTO arm64
builds probably doesn't cover READ_ONCE() accesses?

A quick test seems to confirm this: https://godbolt.org/z/8oYfaExYf