From: Jann Horn Date: Wed, 26 Mar 2025 21:04:36 +0000 (+0100) Subject: rwonce: fix crash by removing READ_ONCE() for unaligned read X-Git-Tag: v6.15-rc1~155^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=47a60391ae0ed04ffbb9bd8dcd94ad9d08b41288;p=thirdparty%2Fkernel%2Flinux.git rwonce: fix crash by removing READ_ONCE() for unaligned read When arm64 is built with LTO, it upgrades READ_ONCE() to ldar / ldapr (load-acquire) to avoid issues that can be caused by the compiler optimizing away implicit address dependencies. Unlike plain loads, these load-acquire instructions actually require an aligned address. For now, fix it by removing the READ_ONCE() that the buggy commit introduced. Fixes: ece69af2ede1 ("rwonce: handle KCSAN like KASAN in read_word_at_a_time()") Reported-by: Nathan Chancellor Closes: https://lore.kernel.org/r/20250326203926.GA10484@ax162 Signed-off-by: Jann Horn Signed-off-by: Arnd Bergmann --- diff --git a/include/asm-generic/rwonce.h b/include/asm-generic/rwonce.h index e9f2b84d2338c..52b969c7cef93 100644 --- a/include/asm-generic/rwonce.h +++ b/include/asm-generic/rwonce.h @@ -86,7 +86,12 @@ unsigned long read_word_at_a_time(const void *addr) kasan_check_read(addr, 1); kcsan_check_read(addr, 1); - return READ_ONCE(*(unsigned long *)addr); + /* + * This load can race with concurrent stores to out-of-bounds memory, + * but READ_ONCE() can't be used because it requires higher alignment + * than plain loads in arm64 builds with LTO. + */ + return *(unsigned long *)addr; } #endif /* __ASSEMBLY__ */