[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251006093750.GS3245006@noisy.programming.kicks-ass.net>
Date: Mon, 6 Oct 2025 11:37:50 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Arnd Bergmann <arnd@...db.de>
Cc: Finn Thain <fthain@...ux-m68k.org>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Will Deacon <will@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Boqun Feng <boqun.feng@...il.com>, Jonathan Corbet <corbet@....net>,
Mark Rutland <mark.rutland@....com>, linux-kernel@...r.kernel.org,
Linux-Arch <linux-arch@...r.kernel.org>, linux-m68k@...r.kernel.org,
Lance Yang <lance.yang@...ux.dev>, elver@...gle.com
Subject: Re: [RFC v2 2/3] atomic: Specify alignment for atomic_t and
atomic64_t
On Tue, Sep 30, 2025 at 08:35:55AM +0200, Arnd Bergmann wrote:
> Since there is nothing telling the compiler that
> the 'old' argument to atomic*_try_cmpcxchg() needs to
> be naturally aligned, maybe that check should be changed
> to only test for the ABI-guaranteed alignment? I think
> that would still be needed on x86-32.
>
> Arnd
>
> diff --git a/include/linux/atomic/atomic-instrumented.h b/include/linux/atomic/atomic-instrumented.h
> index 9409a6ddf3e0..e57763a889bd 100644
> --- a/include/linux/atomic/atomic-instrumented.h
> +++ b/include/linux/atomic/atomic-instrumented.h
> @@ -1276,7 +1276,7 @@ atomic_try_cmpxchg(atomic_t *v, int *old, int new)
> {
> kcsan_mb();
> instrument_atomic_read_write(v, sizeof(*v));
> - instrument_atomic_read_write(old, sizeof(*old));
> + instrument_atomic_read_write(old, alignof(*old));
> return raw_atomic_try_cmpxchg(v, old, new);
> }
That's wrong. The argument there really is size, it tells KASAN how wide
the access is.
Arguably we could switch old to instrument_read_write() since the target
is not actually an atomic.
Powered by blists - more mailing lists