Received: by 2002:a05:6512:3d0e:0:0:0:0 with SMTP id d14csp49967lfv; Tue, 12 Apr 2022 16:52:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNkB3YJv6Rzbm9Vv22E3ZMQ599SMj/wMWz0IPFjFKMpXB4nPZGirPZywUv6R/Jq0BGRi2/ X-Received: by 2002:a05:6a00:724:b0:4fa:a35f:8e0f with SMTP id 4-20020a056a00072400b004faa35f8e0fmr6964545pfm.25.1649807520199; Tue, 12 Apr 2022 16:52:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649807520; cv=none; d=google.com; s=arc-20160816; b=GwV9Eq9UM3aH8fWVhU5+22CxeuUvwOs1kxCNJrolim/NNdx9CcrCJ4jf69R6EVwZ03 a6FGQZZx5DJHyRt+cN49iDS1tf/c0/f8k8rpHQhShRf3zmZKBrcOeE+tH366HpxaD8BR vDHxmk7UyaRNfuZL3K44rioNUdMtAMY7J9Ai+ZFjSg4ZHXPoiX8Z3ZGu7QeRKm6tcp0N Wi7SU5r+bRhHWg1cZIwH23Sj8tT2YfUdLdj28wVpVbsC13lFWGUDUutP+zYFT/cQGAAL hZz1hkXpMhoz0dm/jIHcCzV+0prDFrHZyr0J+kZphNM3xzpiNau9UTZtwHoUh2YVd7Nx KS1Q== 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=y9V333h3nmsVR/oFEmZgYX6lUJXPdi5Ag9YHSNrjfA/8OvZFGwXkPmtNeY5F8Vqn4a I1UXiZQC2zTNlEPuY33pfA5Dioat09xdYlfEsA/SRHIGGJ8DFbOHAWfZbBXcEZR0rL8s ky3QgCrx8kTJw4wZn1pwvEE8ijNO5070wYR8Tpz4FWJSBnVp7/XcTjjBn6XGDeNL80fi t2W15uSUcxhBIcUcQbNe4b7WLGJS43I3Tmv7ytJXnKNBRXhhaydfbV98DlUc2QJgSsqz /kIq3VwMu0vVOe4a7WWiFlkqsXbrRPMEwlDQeyWx/bTteZjc9c1z5+1Sd/klGwWYEm9r eX6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aouW95+R; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id d9-20020a056a00244900b004fa7288d199si13925721pfj.55.2022.04.12.16.51.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 16:52:00 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aouW95+R; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 20C5513926D; Tue, 12 Apr 2022 14:45:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378819AbiDLITV (ORCPT + 99 others); Tue, 12 Apr 2022 04:19:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354812AbiDLH0q (ORCPT ); Tue, 12 Apr 2022 03:26:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 854BC4705D; Tue, 12 Apr 2022 00:06:41 -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 643AA616BF; Tue, 12 Apr 2022 07:06:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 740F8C385A6; Tue, 12 Apr 2022 07:06:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649747200; bh=jdSrlme+ldB8gp5g95tgqulfRXTKB43uz9/V2NDGTck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aouW95+RvvvonF+iYDVrLYEC1hfOTFkA59+SOExMEW85wgxSnavx7nnLoJkYBk+2g 87cZ3niyXN+eTtrin+x8ip/9pUcg3bAkVy60OA0yHHEAHn27ZKFlxFfHD0qcZDvkuL pD9nAPK+wirHRBK3kVmskl5qFqHAHt73S+Dfbn1M= 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.16 278/285] x86/bug: Prevent shadowing in __WARN_FLAGS Date: Tue, 12 Apr 2022 08:32:15 +0200 Message-Id: <20220412062951.677686561@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412062943.670770901@linuxfoundation.org> References: <20220412062943.670770901@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)