Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp637079pxb; Tue, 5 Apr 2022 16:50:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8H7v6fW1vN3VhHmKa+r4CvOn2T/pkEWxPJMM+FBik20hCWPPXSh9OvtQsif8BTqDSVQhc X-Received: by 2002:a17:90a:3e0e:b0:1c7:ca0e:a11 with SMTP id j14-20020a17090a3e0e00b001c7ca0e0a11mr6798163pjc.19.1649202606742; Tue, 05 Apr 2022 16:50:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649202606; cv=none; d=google.com; s=arc-20160816; b=dyiTLGSFaPtLZ25xlfuvjihK/EgL5u5e2CbRAeDdtFdjPuTl76H81Wq4rcIop88nBi OHX1nUpe29vfsMrMc50xwWV1i7yAGlju5FgxOOpgapf2FPlqhErjPuaZLYSONMJcaTLb Q8DqzS289kuLU4H7C14PA5Usqo7DAzujjgO68BcdnwT6cCRx9fIHUv1dS/kvXzzp1HKl uD+QskuLVMmvZ2NjFoc0ctfgy/UWTI0o8RS68iRXQK6zM2nDEpAoW6zMX9+TGLubPnbc anmehWyeK5JVSSdsYUVgSseJqLddbm06VOFvN+Q40wRGsVpUoMGFhRVMxwq3J88oYXAd pyJg== 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=CG5YoLwVtENTsJI0ZrkElUF1kAUax6t9VUJ60RvhJyU=; b=v6FzcAwPRvs1E/KfZMsmuplFOZ+MWRvq1BbzYa+nIFr3MI0KwN6rz5FEB/I+rrZ/SP R0ClA8qu7TXuIkB7F5bHmvtSQQdwy0krb2wCdU3G479PLZbMrCJGBQgF3w7g0INAz2J/ QCq/kQcp9Rzo72Y09KZjk0+R88jBPEbw/iwA1ZA3uoZN1aVGcAZohF5e1CzkEpe4r0fq oftFb6hSVNPY0VgtD7gfwXnPIZSq70sss8xSylk1mdjewxz4h8FnCLi/QhOlsHi/hD9U JNRXnhj8i0OyVpB5AUR41k8WFI8IlNxzAaddfidkafizZQnkxZ4TDA56Tq9NBD35OioU WGZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=wffzHuT9; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k184-20020a636fc1000000b003987c400511si14899616pgc.86.2022.04.05.16.50.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 16:50:06 -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=@linutronix.de header.s=2020 header.b=wffzHuT9; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5780111176C; Tue, 5 Apr 2022 16:34:25 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356914AbiDEKZE (ORCPT + 99 others); Tue, 5 Apr 2022 06:25:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241212AbiDEIcz (ORCPT ); Tue, 5 Apr 2022 04:32:55 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 612A617AA7; Tue, 5 Apr 2022 01:29:41 -0700 (PDT) Date: Tue, 05 Apr 2022 08:29:38 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1649147380; 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=CG5YoLwVtENTsJI0ZrkElUF1kAUax6t9VUJ60RvhJyU=; b=wffzHuT9w4t8vE4ER/eAMk+5e/hBQx8EcbUsg7pU3enhphts0JZ6s2zwslkkAlVo907big 2pXR+XvNOjDvv7UMspTmLAV3ns+Z2HH9F02PvJpSUV/C7gjSKgwzUgVmNGHAeRtFYbK8us pPzBT1YKCWup5r0g8QqsALJ88HlSUY94h8UHi6NvP1sUW/ko+SFf3ObzVh+v6Lt0cEvlbx Crpawo91PVuXsp97UCNud7km3qmxm8GnZLozaxNvdULMdo68xtFYUgU3/CrVjR0do93E9u 0vP9C83d70JL22GkLV/z4yps34Pbx5yN0HXie9y40wNFgBh9+TsncbFcpw8qIQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1649147380; 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=CG5YoLwVtENTsJI0ZrkElUF1kAUax6t9VUJ60RvhJyU=; b=JDN0WqxdBfxFnEc3qfli09GyeYL47oKKnegWtayfWO47xAP0wIs9aW6Vv1T4kDOiTI+k69 6PTMTx8rgs36CCDQ== From: "tip-bot2 for Vincent Mailhol" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/bug: Prevent shadowing in __WARN_FLAGS Cc: Vincent Mailhol , "Peter Zijlstra (Intel)" , Nick Desaulniers , Josh Poimboeuf , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220324023742.106546-1-mailhol.vincent@wanadoo.fr> References: <20220324023742.106546-1-mailhol.vincent@wanadoo.fr> MIME-Version: 1.0 Message-ID: <164914737896.389.7504824366044835648.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,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 The following commit has been merged into the x86/urgent branch of tip: Commit-ID: 9ce02f0fc68326dd1f87a0a3a4c6ae7fdd39e6f6 Gitweb: https://git.kernel.org/tip/9ce02f0fc68326dd1f87a0a3a4c6ae7fdd39e6f6 Author: Vincent Mailhol AuthorDate: Thu, 24 Mar 2022 11:37:42 +09:00 Committer: Peter Zijlstra CommitterDate: Tue, 05 Apr 2022 10:24:40 +02:00 x86/bug: Prevent shadowing in __WARN_FLAGS 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 --- arch/x86/include/asm/bug.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/bug.h b/arch/x86/include/asm/bug.h index 4d20a29..aaf0cb0 100644 --- a/arch/x86/include/asm/bug.h +++ b/arch/x86/include/asm/bug.h @@ -78,9 +78,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)