From nobody Sun Feb 8 05:08:25 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52499C7EE37 for ; Fri, 9 Jun 2023 07:47:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239032AbjFIHrJ (ORCPT ); Fri, 9 Jun 2023 03:47:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239010AbjFIHql (ORCPT ); Fri, 9 Jun 2023 03:46:41 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0985F1FDA; Fri, 9 Jun 2023 00:46:39 -0700 (PDT) Date: Fri, 09 Jun 2023 07:46:36 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686296797; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ALkFxJwcKxaKkbysMd3CGHSOn9xdIigfWesyaC2/HgY=; b=QFYPpxgfBCFvWRAX9TonzR+WIvkeqYQaHkGF/4IsTvD5dz/SmRIjpkKPRPyfQcaojnulgL hXtJWj/zFrYg68YKhdKaxYYWgBSTxokKYY8tvxlEN/0g+aJq5mbg6pzQlHNoSCDYJRBP29 SqvMXPiBQOL4LITNJ7rCH1/TTxt9jK3Y+f/tahbM7MqP4CjQZb+oski4G4D1BpVwYnjr4w 6Grc9BGNa1oJhbuqoRDtHIryvAeZ7M4278F+lGzoI9+Uh6FtgaldJDZJo/mKbXxfbu7uRH am2g3V9N8vFkb7fhmAy6aCwR68xxBUPn+oxrGDt/k6fZncdO5eay/mXxCLaekw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686296797; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ALkFxJwcKxaKkbysMd3CGHSOn9xdIigfWesyaC2/HgY=; b=YDrMYPQc0/286j/g1Bs08E38WZkb1PhERTvHZG3xC0TJuXcTuPNB0JMbD2n8m0VMypSish vR27UKJs/B6lNcAg== From: "tip-bot2 for Nathan Chancellor" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] percpu: Fix self-assignment of __old in raw_cpu_generic_try_cmpxchg() Cc: Nathan Chancellor , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: =?utf-8?q?=3C20230607-fix-shadowing-in-raw=5Fcpu=5Fgeneric=5F?= =?utf-8?q?try=5Fcmpxchg-v1-1-8f0a3d930d43=40kernel=2Eorg=3E?= References: =?utf-8?q?=3C20230607-fix-shadowing-in-raw=5Fcpu=5Fgeneric=5Ft?= =?utf-8?q?ry=5Fcmpxchg-v1-1-8f0a3d930d43=40kernel=2Eorg=3E?= MIME-Version: 1.0 Message-ID: <168629679641.404.10468324915005302564.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the locking/core branch of tip: Commit-ID: 093d9b240a1fa261ff8aeb7c7cc484dedacfda53 Gitweb: https://git.kernel.org/tip/093d9b240a1fa261ff8aeb7c7cc484ded= acfda53 Author: Nathan Chancellor AuthorDate: Wed, 07 Jun 2023 14:20:59 -07:00 Committer: Peter Zijlstra CommitterDate: Thu, 08 Jun 2023 10:28:39 +02:00 percpu: Fix self-assignment of __old in raw_cpu_generic_try_cmpxchg() After commit c5c0ba953b8c ("percpu: Add {raw,this}_cpu_try_cmpxchg()"), clang built ARCH=3Darm and ARCH=3Darm64 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 BTYP= E=3D--) [ 0.000000] pc : alloc_vmap_area+0x7ec/0x7f8 [ 0.000000] lr : alloc_vmap_area+0x7e8/0x7f8 Compiling mm/vmalloc.c with W=3D2 reveals an instance of -Wshadow, which helps uncover that through macro expansion, '__old =3D *(ovalp)' in raw_cpu_generic_try_cmpxchg() can become '__old =3D *(&__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 Fixes: c5c0ba953b8c ("percpu: Add {raw,this}_cpu_try_cmpxchg()") Debugged-by: Nick Desaulniers Signed-off-by: Nathan Chancellor Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20230607-fix-shadowing-in-raw_cpu_generic_t= ry_cmpxchg-v1-1-8f0a3d930d43@kernel.org --- include/asm-generic/percpu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h index 68c410e..94cbd50 100644 --- a/include/asm-generic/percpu.h +++ b/include/asm-generic/percpu.h @@ -101,9 +101,9 @@ do { \ #define raw_cpu_generic_try_cmpxchg(pcp, ovalp, nval) \ ({ \ typeof(pcp) *__p =3D raw_cpu_ptr(&(pcp)); \ - typeof(pcp) __val =3D *__p, __old =3D *(ovalp); \ + typeof(pcp) __val =3D *__p, ___old =3D *(ovalp); \ bool __ret; \ - if (__val =3D=3D __old) { \ + if (__val =3D=3D ___old) { \ *__p =3D nval; \ __ret =3D true; \ } else { \