Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp894583rwd; Thu, 8 Jun 2023 09:07:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5R3DJB/tdb/zErEXE+qg/fRgw7spjOZaSkxgYWpJZ6Ad5N+v+8BUcwGy38AxFDO6Hxi/kY X-Received: by 2002:a05:6a00:1302:b0:65c:1170:6cd4 with SMTP id j2-20020a056a00130200b0065c11706cd4mr10029400pfu.30.1686240425642; Thu, 08 Jun 2023 09:07:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686240425; cv=none; d=google.com; s=arc-20160816; b=rFZ6LjYr2N+Qty6NPAXtgB6c2VJ+D7RbzjSPaBETp4l5xWMSaeTyujP2eWkFmbjKwt 8+mc4rwuXhaNLvKy3QIbahqudJLV0K70Ht+2N9LWBYTBdyQEUbsTv5LjvDq4w8E1DR7F uujNBFRs0CedJEeH6mr4wuRwf7f67BeoEs5n3csVpecOlio3+yBqQA6M7Cuo3EKlpmXA B2/pDsmxoKkRC9xwuF7u1eWQyweKJgcyUi7DHKFL9tcVi8cGzOEVgBalrUVH/q31tsaj PC54RdzSDp+6KDmUh5QhnYmLoOZNLYbhvyilMjdK02YofD2cbrWlQ/wCfyqbGye/S5MM Q8Ew== 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=tc68RIY8iODHY8Hxm5fg68HzLb5N7jDZwkAOiALEJlE=; b=WXbY9ZyK+Y4kbxOaTJVYPljsZlUyW+FlZRvrosXqB3eF08LeBDGAHeBtqJyxrXtWHI GR42JwyGfixclEaf7TaSS1aDtKoj0FWdlGrsygnDvvAPuUXetD+yICT3PZ8NHuK2kcIG vI4NCI34dd+7wbZScE58jaxecz9yIipJhz6CAdW+yPTyGwuw6HhaGaLb+qfEjH5qPohz b0KJufWc8qCx8R5O8arFHavuBsK/LTYMmgf22/g41rfkIBcPfCglAHdDG1hu8V0YyK8X OtWunuPZU26gKLL0cwdCIuAY+/Ef3hMpgayj5bwlBITU+YQSjc8vSQLuFNInGmPsnPe6 M1aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lzlpPucP; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p29-20020aa79e9d000000b006636be3bc45si324737pfq.120.2023.06.08.09.06.49; Thu, 08 Jun 2023 09:07:05 -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=@kernel.org header.s=k20201202 header.b=lzlpPucP; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236922AbjFHPza (ORCPT + 99 others); Thu, 8 Jun 2023 11:55:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235192AbjFHPz3 (ORCPT ); Thu, 8 Jun 2023 11:55:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3FC130CB; Thu, 8 Jun 2023 08:54:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D07BE61864; Thu, 8 Jun 2023 15:54:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD303C433D2; Thu, 8 Jun 2023 15:54:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686239668; bh=KC7pc+HuJtxytfEHmhScpNkrZ2PvzCFEU9GQjwsjh4w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lzlpPucPWYseRIzEorhY5F+Z/bOM2tAu0VrZDhuaaEN844jSZzBC0WfXOaOL0vcnc ZLTqPPVB1W8FV3jkuR+N1aFdpO2CSSdm5npKThdGnWd5OgMoeTxbSj48B4j5AN7P+f Bww0hEZvrPMNKh0OTg+wXrMN5V/cfaH9nHs9Ya6jN2DHO6FlhvIur8pPeGU2L0/JqB YM1iKbTkMnIUk0Mk/u3GTWyYSoTNd6tWKKhWT1787NSAloPpqD2h6uskEeAJk12L8H r8BxVLHL//cOrQgx9OG2IBcTcVFw3aag1jznJM6WivgqhnNyJxcl7NOYacXkTxFZPV AJjt9g7e5A6wQ== Date: Thu, 8 Jun 2023 08:54:26 -0700 From: Nathan Chancellor To: Peter Zijlstra 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: <20230608155426.GA188192@dev-arch.thelio-3990X> References: <20230607-fix-shadowing-in-raw_cpu_generic_try_cmpxchg-v1-1-8f0a3d930d43@kernel.org> <20230608082940.GF998233@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230608082940.GF998233@hirez.programming.kicks-ass.net> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,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 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 > > 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! Thanks for the quick response! Cheers, Nathan