From: Nathan Chancellor <nathan@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: mark.rutland@arm.com, arnd@arndb.de, ndesaulniers@google.com,
trix@redhat.com, linux-arch@vger.kernel.org,
linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
patches@lists.linux.dev
Subject: Re: [PATCH] percpu: Fix self-assignment of __old in raw_cpu_generic_try_cmpxchg()
Date: Thu, 8 Jun 2023 08:54:26 -0700 [thread overview]
Message-ID: <20230608155426.GA188192@dev-arch.thelio-3990X> (raw)
In-Reply-To: <20230608082940.GF998233@hirez.programming.kicks-ass.net>
On Thu, Jun 08, 2023 at 10:29:40AM +0200, Peter Zijlstra wrote:
> On Wed, Jun 07, 2023 at 02:20:59PM -0700, Nathan Chancellor wrote:
> > After commit c5c0ba953b8c ("percpu: Add {raw,this}_cpu_try_cmpxchg()"),
> > clang built ARCH=arm and ARCH=arm64 kernels with CONFIG_INIT_STACK_NONE
> > started panicking on boot in alloc_vmap_area():
> >
> > [ 0.000000] kernel BUG at mm/vmalloc.c:1638!
> > [ 0.000000] Internal error: Oops - BUG: 00000000f2000800 [#1] PREEMPT SMP
> > [ 0.000000] Modules linked in:
> > [ 0.000000] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.4.0-rc2-ARCH+ #1
> > [ 0.000000] Hardware name: linux,dummy-virt (DT)
> > [ 0.000000] pstate: 200000c9 (nzCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
> > [ 0.000000] pc : alloc_vmap_area+0x7ec/0x7f8
> > [ 0.000000] lr : alloc_vmap_area+0x7e8/0x7f8
> >
> > Compiling mm/vmalloc.c with W=2 reveals an instance of -Wshadow, which
> > helps uncover that through macro expansion, '__old = *(ovalp)' in
> > raw_cpu_generic_try_cmpxchg() can become '__old = *(&__old)' through
> > raw_cpu_generic_cmpxchg(), which results in garbage being assigned to
> > the inner __old and the cmpxchg not working properly.
> >
> > Add an extra underscore to __old in raw_cpu_generic_try_cmpxchg() so
> > that there is no more self-assignment, which resolves the panics.
> >
> > Closes: https://github.com/ClangBuiltLinux/linux/issues/1868
>
> First time I see Closes; is this an 'official' tag?
It is, but only recently:
https://git.kernel.org/linus/0d828200ad56505a827610af876ca0b138b943a6
checkpatch.pl wants Closes: after Reported-by: so I have just started
getting into the habit of using it even when I am the reporter :)
> > Debugged-by: Nick Desaulniers <ndesaulniers@google.com>
> > Fixes: c5c0ba953b8c ("percpu: Add {raw,this}_cpu_try_cmpxchg()")
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
>
> Durr, C is such a lovely language :-)
:)
> I'll go stick it in locking/core to go with the bunch that wrecked it.
> Thanks!
Thanks for the quick response!
Cheers,
Nathan
prev parent reply other threads:[~2023-06-08 15:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-07 21:20 [PATCH] percpu: Fix self-assignment of __old in raw_cpu_generic_try_cmpxchg() Nathan Chancellor
2023-06-08 8:29 ` Peter Zijlstra
2023-06-08 15:54 ` Nathan Chancellor [this message]
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=20230608155426.GA188192@dev-arch.thelio-3990X \
--to=nathan@kernel.org \
--cc=arnd@arndb.de \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mark.rutland@arm.com \
--cc=ndesaulniers@google.com \
--cc=patches@lists.linux.dev \
--cc=peterz@infradead.org \
--cc=trix@redhat.com \
/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