Skip to content

Commit 47a6039

Browse files
thejharndb
authored andcommitted
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: ece69af ("rwonce: handle KCSAN like KASAN in read_word_at_a_time()") Reported-by: Nathan Chancellor <nathan@kernel.org> Closes: https://lore.kernel.org/r/20250326203926.GA10484@ax162 Signed-off-by: Jann Horn <jannh@google.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
1 parent ece69af commit 47a6039

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

include/asm-generic/rwonce.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,12 @@ unsigned long read_word_at_a_time(const void *addr)
8686
kasan_check_read(addr, 1);
8787
kcsan_check_read(addr, 1);
8888

89-
return READ_ONCE(*(unsigned long *)addr);
89+
/*
90+
* This load can race with concurrent stores to out-of-bounds memory,
91+
* but READ_ONCE() can't be used because it requires higher alignment
92+
* than plain loads in arm64 builds with LTO.
93+
*/
94+
return *(unsigned long *)addr;
9095
}
9196

9297
#endif /* __ASSEMBLY__ */

0 commit comments

Comments
 (0)