From: "Arnd Bergmann" <arnd@arndb.de>
To: "Jann Horn" <jannh@google.com>
Cc: "Marco Elver" <elver@google.com>,
"Nathan Chancellor" <nathan@kernel.org>,
Linux-Arch <linux-arch@vger.kernel.org>,
linux-kernel@vger.kernel.org,
"Linus Torvalds" <torvalds@linux-foundation.org>
Subject: Re: [PATCH] rwonce: fix crash by removing READ_ONCE() for unaligned read
Date: Wed, 26 Mar 2025 22:23:33 +0100 [thread overview]
Message-ID: <4b412238-b20a-4346-bf67-f31df0a9f259@app.fastmail.com> (raw)
In-Reply-To: <20250326-rwaat-fix-v1-1-600f411eaf23@google.com>
On Wed, Mar 26, 2025, at 22:04, Jann Horn wrote:
> 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 <nathan@kernel.org>
> Closes: https://lore.kernel.org/r/20250326203926.GA10484@ax162
> Signed-off-by: Jann Horn <jannh@google.com>
Thanks for the quick fix!
I've applied this on top of the asm-generic branch, but I just sent
the pull request with the regression to Linus an hour ago.
I'll try to get a new pull request out tomorrow.
Arnd
> ---
> include/asm-generic/rwonce.h | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/include/asm-generic/rwonce.h b/include/asm-generic/rwonce.h
> index e9f2b84d2338..52b969c7cef9 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__ */
>
> ---
> base-commit: ece69af2ede103e190ffdfccd9f9ec850606ab5e
> change-id: 20250326-rwaat-fix-63d7557b3d88
>
> --
> Jann Horn <jannh@google.com>
next prev parent reply other threads:[~2025-03-26 21:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-26 21:04 Jann Horn
2025-03-26 21:23 ` Arnd Bergmann [this message]
2025-03-26 22:41 ` Linus Torvalds
2025-03-26 22:50 ` Jann Horn
2025-03-26 22:54 ` Nathan Chancellor
2025-03-27 0:49 ` Linus Torvalds
2025-03-27 10:58 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4b412238-b20a-4346-bf67-f31df0a9f259@app.fastmail.com \
--to=arnd@arndb.de \
--cc=elver@google.com \
--cc=jannh@google.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nathan@kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®