From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6ECBEC433EF for ; Mon, 30 May 2022 10:53:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235473AbiE3KxO (ORCPT ); Mon, 30 May 2022 06:53:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235296AbiE3KxK (ORCPT ); Mon, 30 May 2022 06:53:10 -0400 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3883252534 for ; Mon, 30 May 2022 03:53:07 -0700 (PDT) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4LBXLn0P3Yz4xZD; Mon, 30 May 2022 20:53:05 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1653907986; bh=Dkvi+HFnbDL2DwAp//5yZB70vhuSooWcV247ZK3BH7k=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=RCZFhtbcPhp6Lug7Q3gshleEqDi7ZuvqwB+nM02fddCWX0aDlm65SzHOVqZw86Aj/ 4xC3Bt3yfwONnf9sSnPlNSYOUpxKhgjYmfchRALVRMhZP09M51niSbFrWNiiK7dQNd WMN1UzdHm3Iykv6om8HKrnwF/u8r0QuBoaeGeCaJMG+4hFBZ0jsFaABKvbpwyqNAvE L9EjjUFZIAM7ouw6qZeT6WRJPYCy+x8D+0q9rLKUllNhJI8C4Rj3GUAPUSmatzOjSt tfCsdy2vE/Je+vFDDbHqQLdqbZpHo6viU34ODQG6WMYFqhYV+0b3MCakzgqjGljCyu +nHi3eexEZT/Q== From: Michael Ellerman To: Petr Mladek , Bagas Sanjaya Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Sergey Senozhatsky , Steven Rostedt , John Ogness , Benjamin Herrenschmidt , Paul Mackerras , David Howells , Jordan Niethe Subject: Re: dangling pointer to '__str' error on ppc64_defconfig, GCC 12.1.0 In-Reply-To: References: Date: Mon, 30 May 2022 20:53:01 +1000 Message-ID: <87k0a3l2b6.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Petr Mladek writes: > On Thu 2022-05-26 16:17:15, Bagas Sanjaya wrote: >> Hi everyone, >> >> Attempting to build ppc64_defconfig kernel with powerpc64-unknown-linux-gnu >> (GCC 12.1.0) on v5.18, I got build error on ftrace.o: >> >> CC arch/powerpc/kernel/trace/ftrace.o >> CC init/init_task.o >> In file included from ./include/asm-generic/bug.h:22, >> from ./arch/powerpc/include/asm/bug.h:156, >> from ./include/linux/bug.h:5, >> from ./include/linux/thread_info.h:13, >> from ./include/asm-generic/preempt.h:5, >> from ./arch/powerpc/include/generated/asm/preempt.h:1, >> from ./include/linux/preempt.h:78, >> from ./include/linux/spinlock.h:55, >> from arch/powerpc/kernel/trace/ftrace.c:16: >> arch/powerpc/kernel/trace/ftrace.c: In function 'ftrace_modify_code': >> ./include/linux/printk.h:446:44: error: using a dangling pointer to '__str' [-Werror=dangling-pointer=] >> 446 | #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__) >> | ^ >> ./include/linux/printk.h:418:17: note: in definition of macro 'printk_index_wrap' >> 418 | _p_func(_fmt, ##__VA_ARGS__); \ >> | ^~~~~~~ >> ./include/linux/printk.h:489:9: note: in expansion of macro 'printk' >> 489 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) >> | ^~~~~~ >> arch/powerpc/kernel/trace/ftrace.c:75:17: note: in expansion of macro 'pr_err' >> 75 | pr_err("%p: replaced (%s) != old (%s)", >> | ^~~~~~ >> In file included from ./arch/powerpc/include/asm/code-patching.h:14, >> from arch/powerpc/kernel/trace/ftrace.c:26: >> ./arch/powerpc/include/asm/inst.h:156:14: note: '__str' declared here >> 156 | char __str[PPC_INST_STR_LEN]; \ >> | ^~~~~ > > IMHO, the problem is in the macro: > > #define ppc_inst_as_str(x) \ > ({ \ > char __str[PPC_INST_STR_LEN]; \ > __ppc_inst_as_str(__str, x); \ > __str; \ > }) > > The buffer __str is defined inside the code block {} and > the macro passes the pointer to the buffer outside. > IMHO, from the compiler POV, the buffer does not exist > outside of the code block. This warning seems kind of incompatible with statement expressions. But I guess the compiler is happy as long as the value returned is not a pointer. So I'm not sure I agree with the compiler here, but too bad for me I guess. This macro has always been a bit awkward, I think I'm inclined to just get rid of it completely, and print the ulong value. I'll send a patch. Anyway it's definitely not your problem, sorry you ended up on Cc. cheers From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E21BCC433EF for ; Mon, 30 May 2022 10:53:44 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4LBXMW0prvz3by6 for ; Mon, 30 May 2022 20:53:43 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ellerman.id.au header.i=@ellerman.id.au header.a=rsa-sha256 header.s=201909 header.b=RCZFhtbc; dkim-atps=neutral Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4LBXLp1ynPz2ywb for ; Mon, 30 May 2022 20:53:06 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ellerman.id.au header.i=@ellerman.id.au header.a=rsa-sha256 header.s=201909 header.b=RCZFhtbc; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4LBXLn0P3Yz4xZD; Mon, 30 May 2022 20:53:05 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1653907986; bh=Dkvi+HFnbDL2DwAp//5yZB70vhuSooWcV247ZK3BH7k=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=RCZFhtbcPhp6Lug7Q3gshleEqDi7ZuvqwB+nM02fddCWX0aDlm65SzHOVqZw86Aj/ 4xC3Bt3yfwONnf9sSnPlNSYOUpxKhgjYmfchRALVRMhZP09M51niSbFrWNiiK7dQNd WMN1UzdHm3Iykv6om8HKrnwF/u8r0QuBoaeGeCaJMG+4hFBZ0jsFaABKvbpwyqNAvE L9EjjUFZIAM7ouw6qZeT6WRJPYCy+x8D+0q9rLKUllNhJI8C4Rj3GUAPUSmatzOjSt tfCsdy2vE/Je+vFDDbHqQLdqbZpHo6viU34ODQG6WMYFqhYV+0b3MCakzgqjGljCyu +nHi3eexEZT/Q== From: Michael Ellerman To: Petr Mladek , Bagas Sanjaya Subject: Re: dangling pointer to '__str' error on ppc64_defconfig, GCC 12.1.0 In-Reply-To: References: Date: Mon, 30 May 2022 20:53:01 +1000 Message-ID: <87k0a3l2b6.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Ogness , linux-kernel@vger.kernel.org, Steven Rostedt , David Howells , Sergey Senozhatsky , Paul Mackerras , Jordan Niethe , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Petr Mladek writes: > On Thu 2022-05-26 16:17:15, Bagas Sanjaya wrote: >> Hi everyone, >> >> Attempting to build ppc64_defconfig kernel with powerpc64-unknown-linux-gnu >> (GCC 12.1.0) on v5.18, I got build error on ftrace.o: >> >> CC arch/powerpc/kernel/trace/ftrace.o >> CC init/init_task.o >> In file included from ./include/asm-generic/bug.h:22, >> from ./arch/powerpc/include/asm/bug.h:156, >> from ./include/linux/bug.h:5, >> from ./include/linux/thread_info.h:13, >> from ./include/asm-generic/preempt.h:5, >> from ./arch/powerpc/include/generated/asm/preempt.h:1, >> from ./include/linux/preempt.h:78, >> from ./include/linux/spinlock.h:55, >> from arch/powerpc/kernel/trace/ftrace.c:16: >> arch/powerpc/kernel/trace/ftrace.c: In function 'ftrace_modify_code': >> ./include/linux/printk.h:446:44: error: using a dangling pointer to '__str' [-Werror=dangling-pointer=] >> 446 | #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__) >> | ^ >> ./include/linux/printk.h:418:17: note: in definition of macro 'printk_index_wrap' >> 418 | _p_func(_fmt, ##__VA_ARGS__); \ >> | ^~~~~~~ >> ./include/linux/printk.h:489:9: note: in expansion of macro 'printk' >> 489 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) >> | ^~~~~~ >> arch/powerpc/kernel/trace/ftrace.c:75:17: note: in expansion of macro 'pr_err' >> 75 | pr_err("%p: replaced (%s) != old (%s)", >> | ^~~~~~ >> In file included from ./arch/powerpc/include/asm/code-patching.h:14, >> from arch/powerpc/kernel/trace/ftrace.c:26: >> ./arch/powerpc/include/asm/inst.h:156:14: note: '__str' declared here >> 156 | char __str[PPC_INST_STR_LEN]; \ >> | ^~~~~ > > IMHO, the problem is in the macro: > > #define ppc_inst_as_str(x) \ > ({ \ > char __str[PPC_INST_STR_LEN]; \ > __ppc_inst_as_str(__str, x); \ > __str; \ > }) > > The buffer __str is defined inside the code block {} and > the macro passes the pointer to the buffer outside. > IMHO, from the compiler POV, the buffer does not exist > outside of the code block. This warning seems kind of incompatible with statement expressions. But I guess the compiler is happy as long as the value returned is not a pointer. So I'm not sure I agree with the compiler here, but too bad for me I guess. This macro has always been a bit awkward, I think I'm inclined to just get rid of it completely, and print the ulong value. I'll send a patch. Anyway it's definitely not your problem, sorry you ended up on Cc. cheers