[tip:,locking/core] percpu: Fix self-assignment of __old in raw_cpu_generic_try_cmpxchg()
Message ID | 168629679641.404.10468324915005302564.tip-bot2@tip-bot2 |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp778020vqr; Fri, 9 Jun 2023 00:49:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6zuvtLv+nGZCVxKcbRvz3dVr2f4v7lYxbx9MlWST2qFu6nnIdZzYNRRgCJOt7AuJq0oX6H X-Received: by 2002:a05:6a20:a987:b0:10f:2abb:c9fd with SMTP id cc7-20020a056a20a98700b0010f2abbc9fdmr292745pzb.43.1686296970027; Fri, 09 Jun 2023 00:49:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686296970; cv=none; d=google.com; s=arc-20160816; b=glieHec0i7c5g5+RqsZ2QkvLCaLU3Cn3bKO54nZPBwW8V+RsKo7G5UlWUN/qaIONLB hOv63Moc5V+liIXTkHzoxr0sgqPYVQYqkh+iyB6QMh7YIwjz41mSZ171wBpAAsoCEoUq p4iyPZfiJXcuQv5W8p59rDOJJm8gr8vwrvoBw6ecQnltoqjiDaqmXxSrH88CKULGVeCc vWDZk8CaicGw4c1gvxgxMR8GD9r/rZgEW+Rq18EhpfZJJIRn51hhPJivsBBPVEkjOg75 8g+UukTGdA1LxPzfURYJzNDjINEehKQ26CXd2CPAAr0ttGTMllQnoUVdy+g+KpnRAUkw kqkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=ALkFxJwcKxaKkbysMd3CGHSOn9xdIigfWesyaC2/HgY=; b=gqREDZQ6ykQqHHLgUeBmqwVh4jy2XmQZbS5QdMcyKRPHMJ0N3sxKHMPds1n5/qNWer GsCJdommHqDif/fFYtqyzZVD/bOo/v085afhi9g6YY406IHT8sqEVCeoDB1R3Yjc/BM7 JQMB5UG0dlywbo81urUkpKm6oZIepATmI2vEsH/kfdg8PYT/G34tRqB+W4oU+QhsIA4K i/o71uj5kptMMKYsA5Yk7sAbWqhgDCvgmOWBjb9mlimkzWUm5rXYJydHXOWxCKzyB+DR 6loX7LUqEdCYX+589jA8Rx/dQFHhCcsiCeF3yp9D7mDYBGGAYoZM7PGqtpHOnVGULPig c9kA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=QFYPpxgf; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z2-20020aa79582000000b0064f6a52105csi2058157pfj.378.2023.06.09.00.49.17; Fri, 09 Jun 2023 00:49:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=QFYPpxgf; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239015AbjFIHrJ (ORCPT <rfc822;liningstudo@gmail.com> + 99 others); 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 <rfc822;linux-kernel@vger.kernel.org>); 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" <tip-bot2@linutronix.de> 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 <nathan@kernel.org>, "Peter Zijlstra (Intel)" <peterz@infradead.org>, x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: =?utf-8?q?=3C20230607-fix-shadowing-in-raw=5Fcpu=5Fgeneric=5Ftr?= =?utf-8?q?y=5Fcmpxchg-v1-1-8f0a3d930d43=40kernel=2Eorg=3E?= References: =?utf-8?q?=3C20230607-fix-shadowing-in-raw=5Fcpu=5Fgeneric=5Ftry?= =?utf-8?q?=5Fcmpxchg-v1-1-8f0a3d930d43=40kernel=2Eorg=3E?= MIME-Version: 1.0 Message-ID: <168629679641.404.10468324915005302564.tip-bot2@tip-bot2> Robot-ID: <tip-bot2@linutronix.de> Robot-Unsubscribe: Contact <mailto:tglx@linutronix.de> to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768081984721720193?= X-GMAIL-MSGID: =?utf-8?q?1768210531768256364?= |
Series |
[tip:,locking/core] percpu: Fix self-assignment of __old in raw_cpu_generic_try_cmpxchg()
|
|
Commit Message
tip-bot2 for Thomas Gleixner
June 9, 2023, 7:46 a.m. UTC
The following commit has been merged into the locking/core branch of tip: Commit-ID: 093d9b240a1fa261ff8aeb7c7cc484dedacfda53 Gitweb: https://git.kernel.org/tip/093d9b240a1fa261ff8aeb7c7cc484dedacfda53 Author: Nathan Chancellor <nathan@kernel.org> AuthorDate: Wed, 07 Jun 2023 14:20:59 -07:00 Committer: Peter Zijlstra <peterz@infradead.org> 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=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 Fixes: c5c0ba953b8c ("percpu: Add {raw,this}_cpu_try_cmpxchg()") Debugged-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20230607-fix-shadowing-in-raw_cpu_generic_try_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 = raw_cpu_ptr(&(pcp)); \ - typeof(pcp) __val = *__p, __old = *(ovalp); \ + typeof(pcp) __val = *__p, ___old = *(ovalp); \ bool __ret; \ - if (__val == __old) { \ + if (__val == ___old) { \ *__p = nval; \ __ret = true; \ } else { \