Received: by 2002:a05:6512:3d0e:0:0:0:0 with SMTP id d14csp42885lfv; Tue, 12 Apr 2022 16:31:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUMOuRUCmWPkPqf0uEpDT3CAHea2f65L79FnILc1Yqi3KuCg38+vBwSYo5dKFmQXfk0nSc X-Received: by 2002:a17:90a:9416:b0:1ca:9cff:7877 with SMTP id r22-20020a17090a941600b001ca9cff7877mr7637251pjo.141.1649806270731; Tue, 12 Apr 2022 16:31:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649806270; cv=none; d=google.com; s=arc-20160816; b=pK094CXCaefIb5j9w8txQmoL3mB+YhwqVbrfmEPnrye4nQQymeeWqNmYEInct5ObGi ZB6Ogu3bQhSYgkZ9NfZL1XN99A2xFsxb8pNQACJa3F1PoIC4hJmNmubNoOaw2cOJczaf 8SqWmF3HShI+wqrSJatnOUXWizWnAllV+dzWI8IF+vruY82uQnAWT6KeCBRzPTj1RgNj w1RXCinFQg2fdMXmVyfjtzpkeK90x4kN/PHqBIqQTMti0cpKl9UfcOzox7hlRYxH5UiF pXQuIochuybMUnUwHibQG4XtSH3M7A/h+lGb+1GCkEgbasQn8EjZlCrdjz6eK/hsYRGW CFbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/J3AKAKBdYVOefdKl6eUPP3V8I9jFSCXdTjr739f3EA=; b=KBG+Qv4nNI2ImfXljDcmbEmdxng0R4gb1RiphohiPnoE+qRTgF3pwtPL9HyflGtPpy oSlvx6WARsMEs8kIV9FXNg7seUsC2Wx6y3RQGNhbbiscb2GxP/2puvLyDsWYI9IwarHw 023c4uTG1ylONqIHzyIwhdO+h9JqiJ1cVWtyb3+vrK6CfAXlF033aio6aWGmal76QiB+ dB3KCSeLqBafuLGdYdKd4hlYZgP6a5aTo3IEqzRZWNAQaRn/Iv2BqPML0e9/GKpKp+gu EOw6MOfcFwsaxYqc4OudV4g+wF0cyGif9j5654YsT8sR3aUjR4XPOmwt9Xgm50xZuOWG L/bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QEqfOneQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id f185-20020a62dbc2000000b005056f4bee63si1533194pfg.377.2022.04.12.16.31.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 16:31:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QEqfOneQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5773315B9BE; Tue, 12 Apr 2022 14:22:53 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386339AbiDLIzQ (ORCPT + 99 others); Tue, 12 Apr 2022 04:55:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359414AbiDLHnB (ORCPT ); Tue, 12 Apr 2022 03:43:01 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94317255AE; Tue, 12 Apr 2022 00:23:05 -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 ams.source.kernel.org (Postfix) with ESMTPS id 3F69BB81B13; Tue, 12 Apr 2022 07:23:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A134DC385A1; Tue, 12 Apr 2022 07:23:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649748183; bh=jdSrlme+ldB8gp5g95tgqulfRXTKB43uz9/V2NDGTck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QEqfOneQftJvc6t7KHCzMdWGm5Cdhg/HPQNsnv64DwPj34k1M3sk7wEMxwqO3t1Sk yNWL2FEGRgoU6jYPAiQIzWYNEUGO5tpD52ZZiz+DjGIqPrbD55lq7GVygtX1gW3qlM uoNQCzjE6zyxNsDGUMhJQdgoEWw68cAA8fwJb/QE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vincent Mailhol , "Peter Zijlstra (Intel)" , Nick Desaulniers , Josh Poimboeuf Subject: [PATCH 5.17 329/343] x86/bug: Prevent shadowing in __WARN_FLAGS Date: Tue, 12 Apr 2022 08:32:27 +0200 Message-Id: <20220412063000.815412501@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062951.095765152@linuxfoundation.org> References: <20220412062951.095765152@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: Vincent Mailhol commit 9ce02f0fc68326dd1f87a0a3a4c6ae7fdd39e6f6 upstream. The macro __WARN_FLAGS() uses a local variable named "f". This being a common name, there is a risk of shadowing other variables. For example, GCC would yield: | In file included from ./include/linux/bug.h:5, | from ./include/linux/cpumask.h:14, | from ./arch/x86/include/asm/cpumask.h:5, | from ./arch/x86/include/asm/msr.h:11, | from ./arch/x86/include/asm/processor.h:22, | from ./arch/x86/include/asm/timex.h:5, | from ./include/linux/timex.h:65, | from ./include/linux/time32.h:13, | from ./include/linux/time.h:60, | from ./include/linux/stat.h:19, | from ./include/linux/module.h:13, | from virt/lib/irqbypass.mod.c:1: | ./include/linux/rcupdate.h: In function 'rcu_head_after_call_rcu': | ./arch/x86/include/asm/bug.h:80:21: warning: declaration of 'f' shadows a parameter [-Wshadow] | 80 | __auto_type f = BUGFLAG_WARNING|(flags); \ | | ^ | ./include/asm-generic/bug.h:106:17: note: in expansion of macro '__WARN_FLAGS' | 106 | __WARN_FLAGS(BUGFLAG_ONCE | \ | | ^~~~~~~~~~~~ | ./include/linux/rcupdate.h:1007:9: note: in expansion of macro 'WARN_ON_ONCE' | 1007 | WARN_ON_ONCE(func != (rcu_callback_t)~0L); | | ^~~~~~~~~~~~ | In file included from ./include/linux/rbtree.h:24, | from ./include/linux/mm_types.h:11, | from ./include/linux/buildid.h:5, | from ./include/linux/module.h:14, | from virt/lib/irqbypass.mod.c:1: | ./include/linux/rcupdate.h:1001:62: note: shadowed declaration is here | 1001 | rcu_head_after_call_rcu(struct rcu_head *rhp, rcu_callback_t f) | | ~~~~~~~~~~~~~~~^ For reference, sparse also warns about it, c.f. [1]. This patch renames the variable from f to __flags (with two underscore prefixes as suggested in the Linux kernel coding style [2]) in order to prevent collisions. [1] https://lore.kernel.org/all/CAFGhKbyifH1a+nAMCvWM88TK6fpNPdzFtUXPmRGnnQeePV+1sw@mail.gmail.com/ [2] Linux kernel coding style, section 12) Macros, Enums and RTL, paragraph 5) namespace collisions when defining local variables in macros resembling functions https://www.kernel.org/doc/html/latest/process/coding-style.html#macros-enums-and-rtl Fixes: bfb1a7c91fb7 ("x86/bug: Merge annotate_reachable() into_BUG_FLAGS() asm") Signed-off-by: Vincent Mailhol Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Nick Desaulniers Acked-by: Josh Poimboeuf Link: https://lkml.kernel.org/r/20220324023742.106546-1-mailhol.vincent@wanadoo.fr Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/bug.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/x86/include/asm/bug.h +++ b/arch/x86/include/asm/bug.h @@ -77,9 +77,9 @@ do { \ */ #define __WARN_FLAGS(flags) \ do { \ - __auto_type f = BUGFLAG_WARNING|(flags); \ + __auto_type __flags = BUGFLAG_WARNING|(flags); \ instrumentation_begin(); \ - _BUG_FLAGS(ASM_UD2, f, ASM_REACHABLE); \ + _BUG_FLAGS(ASM_UD2, __flags, ASM_REACHABLE); \ instrumentation_end(); \ } while (0)