[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230608082940.GF998233@hirez.programming.kicks-ass.net>
Date: Thu, 8 Jun 2023 10:29:40 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Nathan Chancellor <nathan@...nel.org>
Cc: mark.rutland@....com, arnd@...db.de, ndesaulniers@...gle.com,
trix@...hat.com, linux-arch@...r.kernel.org,
linux-kernel@...r.kernel.org, llvm@...ts.linux.dev,
patches@...ts.linux.dev
Subject: Re: [PATCH] percpu: Fix self-assignment of __old in
raw_cpu_generic_try_cmpxchg()
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?
> Debugged-by: Nick Desaulniers <ndesaulniers@...gle.com>
> Fixes: c5c0ba953b8c ("percpu: Add {raw,this}_cpu_try_cmpxchg()")
> Signed-off-by: Nathan Chancellor <nathan@...nel.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!
Powered by blists - more mailing lists