Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp376434rwd; Thu, 8 Jun 2023 01:51:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7s5kyjmWZSZpwEQxzWROWh6/Z+u+NwGzuP7fyAhd/U5li9OpCgmnDxWIdZveu3DAH88ORt X-Received: by 2002:a92:d847:0:b0:338:6ace:dd62 with SMTP id h7-20020a92d847000000b003386acedd62mr6204762ilq.14.1686214302043; Thu, 08 Jun 2023 01:51:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686214302; cv=none; d=google.com; s=arc-20160816; b=kA9ZWP4l0G9uTttX7ufmgpiMlYFU92/oX4h4lJJlYr2aLuV0sXGv9nP373MBMCBzji iST3aMhoZTp07mhaABzLxBX0BFFm9F7lzb4pz9LiCaxVgz4n8Zkoht6DZ6i28sIJBXfz eJDkB9EIMJXIHsydM5q5jrNnmy7JfA/PPPA88hS8WMqdvEAdWuSlqpw7Y02t+8ewIUpu tm2QWFT/PxJlNIf8JNUU9goXfZIm7fBF+KjBNeOIDBZelLj0ByUvFjk4Kv4dlF5pBwpk XYj0gePMDMd2kohXmytliMdW0jotJEXxoTeaNIQR0uPRarVGQYGizX60XBbRof28mfp4 DvrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=dtEYRmo7Mb4HUPwmNIi7aG7beCq9+eQ8V/5sHbI/Q38=; b=OsfoC7HesLHCWFr/BzOZCJ0xzCxpYW//0Vs0HOFynrUbAYFuc/Vp4YAu/+Jq+raCy1 yX0ekpqJJeu5O3GEA2FbPO+R17KlK1C0MID77Wk2AwEROoqNwxyqwVfMwwKS7kH41aGT /q1dwpsLl1jE4xiMdCcLelh/a6wM6s+c2wKvX9543tRLGdZ4QPAJdmr/oiktlm6N58GL uJRxwH3E08LrOdPT8ZmUUMXITVH2Q701IFv6RvRYsyN7EoZ4w1N83UKf3nBqrUkdqJHM Y+uvH/HFMVCJyZjFQ3KyGmty+QFc+xyuWW7T21rRm9qsZRNi/weJoHzuo3vxa41hz3fr uyog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=hBBKScrU; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 23-20020a630017000000b0054299598800si664324pga.535.2023.06.08.01.51.27; Thu, 08 Jun 2023 01:51:42 -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=@infradead.org header.s=desiato.20200630 header.b=hBBKScrU; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233743AbjFHIaE (ORCPT + 99 others); Thu, 8 Jun 2023 04:30:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235491AbjFHIaA (ORCPT ); Thu, 8 Jun 2023 04:30:00 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A15DC2700; Thu, 8 Jun 2023 01:29:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=dtEYRmo7Mb4HUPwmNIi7aG7beCq9+eQ8V/5sHbI/Q38=; b=hBBKScrUI1BSKFTaY5cRW0O5DK 6A8/XsHkCD6vbgeQUP8jxDFsg1DqqsIsyjeTU7dvMGCeHlAkHJmca43pwPV0RMQMSv9QIji7wOGV4 iSYfxwy36sAG16PNED0NJ+yagL2152BVszOq5AHtjtlxY3OE2k3kTqc5lzsH3zW64jqe6DQBt5tsp f77I0iL7TCIQir8d9+/YkvIM6BGOcb70scybid46M5a2MBAUbbxj8U9pIycSDMkn56DKXWic/nGH8 srrTdzOOkiSfjyKEl9fkKut8jAPFv4gdzuuVJ2guD0ptKWXIXzrgHD2Hz3Ti89DXajthrOewvBa22 blwutyZw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1q7B1a-0069YO-18; Thu, 08 Jun 2023 08:29:43 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 28BE9300222; Thu, 8 Jun 2023 10:29:41 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 02C7120D72191; Thu, 8 Jun 2023 10:29:40 +0200 (CEST) Date: Thu, 8 Jun 2023 10:29:40 +0200 From: Peter Zijlstra To: Nathan Chancellor 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() Message-ID: <20230608082940.GF998233@hirez.programming.kicks-ass.net> References: <20230607-fix-shadowing-in-raw_cpu_generic_try_cmpxchg-v1-1-8f0a3d930d43@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230607-fix-shadowing-in-raw_cpu_generic_try_cmpxchg-v1-1-8f0a3d930d43@kernel.org> 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_NONE,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Fixes: c5c0ba953b8c ("percpu: Add {raw,this}_cpu_try_cmpxchg()") > Signed-off-by: Nathan Chancellor Durr, C is such a lovely language :-) I'll go stick it in locking/core to go with the bunch that wrecked it. Thanks!