All of lore.kernel.org
 help / color / mirror / Atom feed
* dangling pointer to '__str' error on ppc64_defconfig, GCC 12.1.0
@ 2022-05-26  9:17 ` Bagas Sanjaya
  0 siblings, 0 replies; 6+ messages in thread
From: Bagas Sanjaya @ 2022-05-26  9:17 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: linux-kernel, Petr Mladek, Sergey Senozhatsky, Steven Rostedt,
	John Ogness, Michael Ellerman, Benjamin Herrenschmidt,
	Paul Mackerras, David Howells

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];   \
      |              ^~~~~
./include/linux/printk.h:418:33: note: in expansion of macro 'ppc_inst_as_str'
  418 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
      |                                 ^~~~~~~~~~~
./include/linux/printk.h:446:26: note: in expansion of macro 'printk_index_wrap'
  446 | #define printk(fmt, ...) printk_index_wrap(_printk, 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)",
      |                 ^~~~~~
arch/powerpc/kernel/trace/ftrace.c: In function '__ftrace_make_nop_kernel':
./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:379:17: note: in expansion of macro 'pr_err'
  379 |                 pr_err("Not expected bl: opcode is %s\n", ppc_inst_as_str(op));
      |                 ^~~~~~
./arch/powerpc/include/asm/inst.h:156:14: note: '__str' declared here
  156 |         char __str[PPC_INST_STR_LEN];   \
      |              ^~~~~
./include/linux/printk.h:418:33: note: in expansion of macro 'ppc_inst_as_str'
  418 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
      |                                 ^~~~~~~~~~~
./include/linux/printk.h:446:26: note: in expansion of macro 'printk_index_wrap'
  446 | #define printk(fmt, ...) printk_index_wrap(_printk, 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:379:17: note: in expansion of macro 'pr_err'
  379 |                 pr_err("Not expected bl: opcode is %s\n", ppc_inst_as_str(op));
      |                 ^~~~~~
arch/powerpc/kernel/trace/ftrace.c: In function '__ftrace_make_call_kernel':
./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:638:17: note: in expansion of macro 'pr_err'
  638 |                 pr_err("Unexpected call sequence at %p: %s\n", ip, ppc_inst_as_str(op));
      |                 ^~~~~~
./arch/powerpc/include/asm/inst.h:156:14: note: '__str' declared here
  156 |         char __str[PPC_INST_STR_LEN];   \
      |              ^~~~~
./include/linux/printk.h:418:33: note: in expansion of macro 'ppc_inst_as_str'
  418 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
      |                                 ^~~~~~~~~~~
./include/linux/printk.h:446:26: note: in expansion of macro 'printk_index_wrap'
  446 | #define printk(fmt, ...) printk_index_wrap(_printk, 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:638:17: note: in expansion of macro 'pr_err'
  638 |                 pr_err("Unexpected call sequence at %p: %s\n", ip, ppc_inst_as_str(op));
      |                 ^~~~~~
arch/powerpc/kernel/trace/ftrace.c: In function '__ftrace_make_nop':
./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:205:17: note: in expansion of macro 'pr_err'
  205 |                 pr_err("Expected %08lx found %s\n", PPC_INST_LD_TOC, ppc_inst_as_str(op));
      |                 ^~~~~~
./arch/powerpc/include/asm/inst.h:156:14: note: '__str' declared here
  156 |         char __str[PPC_INST_STR_LEN];   \
      |              ^~~~~
./include/linux/printk.h:418:33: note: in expansion of macro 'ppc_inst_as_str'
  418 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
      |                                 ^~~~~~~~~~~
./include/linux/printk.h:446:26: note: in expansion of macro 'printk_index_wrap'
  446 | #define printk(fmt, ...) printk_index_wrap(_printk, 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:205:17: note: in expansion of macro 'pr_err'
  205 |                 pr_err("Expected %08lx found %s\n", PPC_INST_LD_TOC, ppc_inst_as_str(op));
      |                 ^~~~~~
./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:139:17: note: in expansion of macro 'pr_err'
  139 |                 pr_err("Not expected bl: opcode is %s\n", ppc_inst_as_str(op));
      |                 ^~~~~~
./arch/powerpc/include/asm/inst.h:156:14: note: '__str' declared here
  156 |         char __str[PPC_INST_STR_LEN];   \
      |              ^~~~~
./include/linux/printk.h:418:33: note: in expansion of macro 'ppc_inst_as_str'
  418 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
      |                                 ^~~~~~~~~~~
./include/linux/printk.h:446:26: note: in expansion of macro 'printk_index_wrap'
  446 | #define printk(fmt, ...) printk_index_wrap(_printk, 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:139:17: note: in expansion of macro 'pr_err'
  139 |                 pr_err("Not expected bl: opcode is %s\n", ppc_inst_as_str(op));
      |                 ^~~~~~
arch/powerpc/kernel/trace/ftrace.c: In function '__ftrace_make_call':
./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:506:17: note: in expansion of macro 'pr_err'
  506 |                 pr_err("Unexpected call sequence at %p: %s %s\n",
      |                 ^~~~~~
./arch/powerpc/include/asm/inst.h:156:14: note: '__str' declared here
  156 |         char __str[PPC_INST_STR_LEN];   \
      |              ^~~~~
./include/linux/printk.h:418:33: note: in expansion of macro 'ppc_inst_as_str'
  418 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
      |                                 ^~~~~~~~~~~
./include/linux/printk.h:446:26: note: in expansion of macro 'printk_index_wrap'
  446 | #define printk(fmt, ...) printk_index_wrap(_printk, 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:506:17: note: in expansion of macro 'pr_err'
  506 |                 pr_err("Unexpected call sequence at %p: %s %s\n",
      |                 ^~~~~~
cc1: all warnings being treated as errors
make[3]: *** [scripts/Makefile.build:288: arch/powerpc/kernel/trace/ftrace.o] Error 1

I also hit this error on current master (commit babf0bb978e3c9
("Merge tag 'xfs-5.19-for-linus' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux")).

Thanks.

Reported-by: Bagas Sanjaya <bagasdotme@gmail.com>

-- 
An old man doll... just what I always wanted! - Clara

^ permalink raw reply	[flat|nested] 6+ messages in thread

* dangling pointer to '__str' error on ppc64_defconfig, GCC 12.1.0
@ 2022-05-26  9:17 ` Bagas Sanjaya
  0 siblings, 0 replies; 6+ messages in thread
From: Bagas Sanjaya @ 2022-05-26  9:17 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Petr Mladek, John Ogness, linux-kernel, Steven Rostedt,
	David Howells, Sergey Senozhatsky, Paul Mackerras

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];   \
      |              ^~~~~
./include/linux/printk.h:418:33: note: in expansion of macro 'ppc_inst_as_str'
  418 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
      |                                 ^~~~~~~~~~~
./include/linux/printk.h:446:26: note: in expansion of macro 'printk_index_wrap'
  446 | #define printk(fmt, ...) printk_index_wrap(_printk, 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)",
      |                 ^~~~~~
arch/powerpc/kernel/trace/ftrace.c: In function '__ftrace_make_nop_kernel':
./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:379:17: note: in expansion of macro 'pr_err'
  379 |                 pr_err("Not expected bl: opcode is %s\n", ppc_inst_as_str(op));
      |                 ^~~~~~
./arch/powerpc/include/asm/inst.h:156:14: note: '__str' declared here
  156 |         char __str[PPC_INST_STR_LEN];   \
      |              ^~~~~
./include/linux/printk.h:418:33: note: in expansion of macro 'ppc_inst_as_str'
  418 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
      |                                 ^~~~~~~~~~~
./include/linux/printk.h:446:26: note: in expansion of macro 'printk_index_wrap'
  446 | #define printk(fmt, ...) printk_index_wrap(_printk, 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:379:17: note: in expansion of macro 'pr_err'
  379 |                 pr_err("Not expected bl: opcode is %s\n", ppc_inst_as_str(op));
      |                 ^~~~~~
arch/powerpc/kernel/trace/ftrace.c: In function '__ftrace_make_call_kernel':
./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:638:17: note: in expansion of macro 'pr_err'
  638 |                 pr_err("Unexpected call sequence at %p: %s\n", ip, ppc_inst_as_str(op));
      |                 ^~~~~~
./arch/powerpc/include/asm/inst.h:156:14: note: '__str' declared here
  156 |         char __str[PPC_INST_STR_LEN];   \
      |              ^~~~~
./include/linux/printk.h:418:33: note: in expansion of macro 'ppc_inst_as_str'
  418 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
      |                                 ^~~~~~~~~~~
./include/linux/printk.h:446:26: note: in expansion of macro 'printk_index_wrap'
  446 | #define printk(fmt, ...) printk_index_wrap(_printk, 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:638:17: note: in expansion of macro 'pr_err'
  638 |                 pr_err("Unexpected call sequence at %p: %s\n", ip, ppc_inst_as_str(op));
      |                 ^~~~~~
arch/powerpc/kernel/trace/ftrace.c: In function '__ftrace_make_nop':
./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:205:17: note: in expansion of macro 'pr_err'
  205 |                 pr_err("Expected %08lx found %s\n", PPC_INST_LD_TOC, ppc_inst_as_str(op));
      |                 ^~~~~~
./arch/powerpc/include/asm/inst.h:156:14: note: '__str' declared here
  156 |         char __str[PPC_INST_STR_LEN];   \
      |              ^~~~~
./include/linux/printk.h:418:33: note: in expansion of macro 'ppc_inst_as_str'
  418 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
      |                                 ^~~~~~~~~~~
./include/linux/printk.h:446:26: note: in expansion of macro 'printk_index_wrap'
  446 | #define printk(fmt, ...) printk_index_wrap(_printk, 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:205:17: note: in expansion of macro 'pr_err'
  205 |                 pr_err("Expected %08lx found %s\n", PPC_INST_LD_TOC, ppc_inst_as_str(op));
      |                 ^~~~~~
./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:139:17: note: in expansion of macro 'pr_err'
  139 |                 pr_err("Not expected bl: opcode is %s\n", ppc_inst_as_str(op));
      |                 ^~~~~~
./arch/powerpc/include/asm/inst.h:156:14: note: '__str' declared here
  156 |         char __str[PPC_INST_STR_LEN];   \
      |              ^~~~~
./include/linux/printk.h:418:33: note: in expansion of macro 'ppc_inst_as_str'
  418 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
      |                                 ^~~~~~~~~~~
./include/linux/printk.h:446:26: note: in expansion of macro 'printk_index_wrap'
  446 | #define printk(fmt, ...) printk_index_wrap(_printk, 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:139:17: note: in expansion of macro 'pr_err'
  139 |                 pr_err("Not expected bl: opcode is %s\n", ppc_inst_as_str(op));
      |                 ^~~~~~
arch/powerpc/kernel/trace/ftrace.c: In function '__ftrace_make_call':
./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:506:17: note: in expansion of macro 'pr_err'
  506 |                 pr_err("Unexpected call sequence at %p: %s %s\n",
      |                 ^~~~~~
./arch/powerpc/include/asm/inst.h:156:14: note: '__str' declared here
  156 |         char __str[PPC_INST_STR_LEN];   \
      |              ^~~~~
./include/linux/printk.h:418:33: note: in expansion of macro 'ppc_inst_as_str'
  418 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
      |                                 ^~~~~~~~~~~
./include/linux/printk.h:446:26: note: in expansion of macro 'printk_index_wrap'
  446 | #define printk(fmt, ...) printk_index_wrap(_printk, 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:506:17: note: in expansion of macro 'pr_err'
  506 |                 pr_err("Unexpected call sequence at %p: %s %s\n",
      |                 ^~~~~~
cc1: all warnings being treated as errors
make[3]: *** [scripts/Makefile.build:288: arch/powerpc/kernel/trace/ftrace.o] Error 1

I also hit this error on current master (commit babf0bb978e3c9
("Merge tag 'xfs-5.19-for-linus' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux")).

Thanks.

Reported-by: Bagas Sanjaya <bagasdotme@gmail.com>

-- 
An old man doll... just what I always wanted! - Clara

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: dangling pointer to '__str' error on ppc64_defconfig, GCC 12.1.0
  2022-05-26  9:17 ` Bagas Sanjaya
@ 2022-05-26 13:19   ` Petr Mladek
  -1 siblings, 0 replies; 6+ messages in thread
From: Petr Mladek @ 2022-05-26 13:19 UTC (permalink / raw)
  To: Bagas Sanjaya
  Cc: linuxppc-dev, linux-kernel, Sergey Senozhatsky, Steven Rostedt,
	John Ogness, Michael Ellerman, Benjamin Herrenschmidt,
	Paul Mackerras, David Howells, Jordan Niethe

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.

The macro was added by the commit 50428fdc53ba48f6936b10dfd ("powerpc:
Add a ppc_inst_as_str() helper").

Adding Jordan Niethe into Cc.

Best Regards,
Petr


> ./include/linux/printk.h:418:33: note: in expansion of macro 'ppc_inst_as_str'
>   418 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
>       |                                 ^~~~~~~~~~~
> ./include/linux/printk.h:446:26: note: in expansion of macro 'printk_index_wrap'
>   446 | #define printk(fmt, ...) printk_index_wrap(_printk, 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)",
>       |                 ^~~~~~
> arch/powerpc/kernel/trace/ftrace.c: In function '__ftrace_make_nop_kernel':
> ./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:379:17: note: in expansion of macro 'pr_err'
>   379 |                 pr_err("Not expected bl: opcode is %s\n", ppc_inst_as_str(op));
>       |                 ^~~~~~
> ./arch/powerpc/include/asm/inst.h:156:14: note: '__str' declared here
>   156 |         char __str[PPC_INST_STR_LEN];   \
>       |              ^~~~~
> ./include/linux/printk.h:418:33: note: in expansion of macro 'ppc_inst_as_str'
>   418 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
>       |                                 ^~~~~~~~~~~
> ./include/linux/printk.h:446:26: note: in expansion of macro 'printk_index_wrap'
>   446 | #define printk(fmt, ...) printk_index_wrap(_printk, 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:379:17: note: in expansion of macro 'pr_err'
>   379 |                 pr_err("Not expected bl: opcode is %s\n", ppc_inst_as_str(op));
>       |                 ^~~~~~
> arch/powerpc/kernel/trace/ftrace.c: In function '__ftrace_make_call_kernel':
> ./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:638:17: note: in expansion of macro 'pr_err'
>   638 |                 pr_err("Unexpected call sequence at %p: %s\n", ip, ppc_inst_as_str(op));
>       |                 ^~~~~~
> ./arch/powerpc/include/asm/inst.h:156:14: note: '__str' declared here
>   156 |         char __str[PPC_INST_STR_LEN];   \
>       |              ^~~~~
> ./include/linux/printk.h:418:33: note: in expansion of macro 'ppc_inst_as_str'
>   418 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
>       |                                 ^~~~~~~~~~~
> ./include/linux/printk.h:446:26: note: in expansion of macro 'printk_index_wrap'
>   446 | #define printk(fmt, ...) printk_index_wrap(_printk, 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:638:17: note: in expansion of macro 'pr_err'
>   638 |                 pr_err("Unexpected call sequence at %p: %s\n", ip, ppc_inst_as_str(op));
>       |                 ^~~~~~
> arch/powerpc/kernel/trace/ftrace.c: In function '__ftrace_make_nop':
> ./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:205:17: note: in expansion of macro 'pr_err'
>   205 |                 pr_err("Expected %08lx found %s\n", PPC_INST_LD_TOC, ppc_inst_as_str(op));
>       |                 ^~~~~~
> ./arch/powerpc/include/asm/inst.h:156:14: note: '__str' declared here
>   156 |         char __str[PPC_INST_STR_LEN];   \
>       |              ^~~~~
> ./include/linux/printk.h:418:33: note: in expansion of macro 'ppc_inst_as_str'
>   418 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
>       |                                 ^~~~~~~~~~~
> ./include/linux/printk.h:446:26: note: in expansion of macro 'printk_index_wrap'
>   446 | #define printk(fmt, ...) printk_index_wrap(_printk, 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:205:17: note: in expansion of macro 'pr_err'
>   205 |                 pr_err("Expected %08lx found %s\n", PPC_INST_LD_TOC, ppc_inst_as_str(op));
>       |                 ^~~~~~
> ./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:139:17: note: in expansion of macro 'pr_err'
>   139 |                 pr_err("Not expected bl: opcode is %s\n", ppc_inst_as_str(op));
>       |                 ^~~~~~
> ./arch/powerpc/include/asm/inst.h:156:14: note: '__str' declared here
>   156 |         char __str[PPC_INST_STR_LEN];   \
>       |              ^~~~~
> ./include/linux/printk.h:418:33: note: in expansion of macro 'ppc_inst_as_str'
>   418 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
>       |                                 ^~~~~~~~~~~
> ./include/linux/printk.h:446:26: note: in expansion of macro 'printk_index_wrap'
>   446 | #define printk(fmt, ...) printk_index_wrap(_printk, 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:139:17: note: in expansion of macro 'pr_err'
>   139 |                 pr_err("Not expected bl: opcode is %s\n", ppc_inst_as_str(op));
>       |                 ^~~~~~
> arch/powerpc/kernel/trace/ftrace.c: In function '__ftrace_make_call':
> ./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:506:17: note: in expansion of macro 'pr_err'
>   506 |                 pr_err("Unexpected call sequence at %p: %s %s\n",
>       |                 ^~~~~~
> ./arch/powerpc/include/asm/inst.h:156:14: note: '__str' declared here
>   156 |         char __str[PPC_INST_STR_LEN];   \
>       |              ^~~~~
> ./include/linux/printk.h:418:33: note: in expansion of macro 'ppc_inst_as_str'
>   418 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
>       |                                 ^~~~~~~~~~~
> ./include/linux/printk.h:446:26: note: in expansion of macro 'printk_index_wrap'
>   446 | #define printk(fmt, ...) printk_index_wrap(_printk, 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:506:17: note: in expansion of macro 'pr_err'
>   506 |                 pr_err("Unexpected call sequence at %p: %s %s\n",
>       |                 ^~~~~~
> cc1: all warnings being treated as errors
> make[3]: *** [scripts/Makefile.build:288: arch/powerpc/kernel/trace/ftrace.o] Error 1
> 
> I also hit this error on current master (commit babf0bb978e3c9
> ("Merge tag 'xfs-5.19-for-linus' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux")).
> 
> Thanks.
> 
> Reported-by: Bagas Sanjaya <bagasdotme@gmail.com>
> 
> -- 
> An old man doll... just what I always wanted! - Clara

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: dangling pointer to '__str' error on ppc64_defconfig, GCC 12.1.0
@ 2022-05-26 13:19   ` Petr Mladek
  0 siblings, 0 replies; 6+ messages in thread
From: Petr Mladek @ 2022-05-26 13:19 UTC (permalink / raw)
  To: Bagas Sanjaya
  Cc: John Ogness, linux-kernel, Steven Rostedt, David Howells,
	Sergey Senozhatsky, Jordan Niethe, Paul Mackerras, linuxppc-dev

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.

The macro was added by the commit 50428fdc53ba48f6936b10dfd ("powerpc:
Add a ppc_inst_as_str() helper").

Adding Jordan Niethe into Cc.

Best Regards,
Petr


> ./include/linux/printk.h:418:33: note: in expansion of macro 'ppc_inst_as_str'
>   418 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
>       |                                 ^~~~~~~~~~~
> ./include/linux/printk.h:446:26: note: in expansion of macro 'printk_index_wrap'
>   446 | #define printk(fmt, ...) printk_index_wrap(_printk, 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)",
>       |                 ^~~~~~
> arch/powerpc/kernel/trace/ftrace.c: In function '__ftrace_make_nop_kernel':
> ./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:379:17: note: in expansion of macro 'pr_err'
>   379 |                 pr_err("Not expected bl: opcode is %s\n", ppc_inst_as_str(op));
>       |                 ^~~~~~
> ./arch/powerpc/include/asm/inst.h:156:14: note: '__str' declared here
>   156 |         char __str[PPC_INST_STR_LEN];   \
>       |              ^~~~~
> ./include/linux/printk.h:418:33: note: in expansion of macro 'ppc_inst_as_str'
>   418 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
>       |                                 ^~~~~~~~~~~
> ./include/linux/printk.h:446:26: note: in expansion of macro 'printk_index_wrap'
>   446 | #define printk(fmt, ...) printk_index_wrap(_printk, 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:379:17: note: in expansion of macro 'pr_err'
>   379 |                 pr_err("Not expected bl: opcode is %s\n", ppc_inst_as_str(op));
>       |                 ^~~~~~
> arch/powerpc/kernel/trace/ftrace.c: In function '__ftrace_make_call_kernel':
> ./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:638:17: note: in expansion of macro 'pr_err'
>   638 |                 pr_err("Unexpected call sequence at %p: %s\n", ip, ppc_inst_as_str(op));
>       |                 ^~~~~~
> ./arch/powerpc/include/asm/inst.h:156:14: note: '__str' declared here
>   156 |         char __str[PPC_INST_STR_LEN];   \
>       |              ^~~~~
> ./include/linux/printk.h:418:33: note: in expansion of macro 'ppc_inst_as_str'
>   418 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
>       |                                 ^~~~~~~~~~~
> ./include/linux/printk.h:446:26: note: in expansion of macro 'printk_index_wrap'
>   446 | #define printk(fmt, ...) printk_index_wrap(_printk, 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:638:17: note: in expansion of macro 'pr_err'
>   638 |                 pr_err("Unexpected call sequence at %p: %s\n", ip, ppc_inst_as_str(op));
>       |                 ^~~~~~
> arch/powerpc/kernel/trace/ftrace.c: In function '__ftrace_make_nop':
> ./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:205:17: note: in expansion of macro 'pr_err'
>   205 |                 pr_err("Expected %08lx found %s\n", PPC_INST_LD_TOC, ppc_inst_as_str(op));
>       |                 ^~~~~~
> ./arch/powerpc/include/asm/inst.h:156:14: note: '__str' declared here
>   156 |         char __str[PPC_INST_STR_LEN];   \
>       |              ^~~~~
> ./include/linux/printk.h:418:33: note: in expansion of macro 'ppc_inst_as_str'
>   418 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
>       |                                 ^~~~~~~~~~~
> ./include/linux/printk.h:446:26: note: in expansion of macro 'printk_index_wrap'
>   446 | #define printk(fmt, ...) printk_index_wrap(_printk, 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:205:17: note: in expansion of macro 'pr_err'
>   205 |                 pr_err("Expected %08lx found %s\n", PPC_INST_LD_TOC, ppc_inst_as_str(op));
>       |                 ^~~~~~
> ./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:139:17: note: in expansion of macro 'pr_err'
>   139 |                 pr_err("Not expected bl: opcode is %s\n", ppc_inst_as_str(op));
>       |                 ^~~~~~
> ./arch/powerpc/include/asm/inst.h:156:14: note: '__str' declared here
>   156 |         char __str[PPC_INST_STR_LEN];   \
>       |              ^~~~~
> ./include/linux/printk.h:418:33: note: in expansion of macro 'ppc_inst_as_str'
>   418 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
>       |                                 ^~~~~~~~~~~
> ./include/linux/printk.h:446:26: note: in expansion of macro 'printk_index_wrap'
>   446 | #define printk(fmt, ...) printk_index_wrap(_printk, 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:139:17: note: in expansion of macro 'pr_err'
>   139 |                 pr_err("Not expected bl: opcode is %s\n", ppc_inst_as_str(op));
>       |                 ^~~~~~
> arch/powerpc/kernel/trace/ftrace.c: In function '__ftrace_make_call':
> ./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:506:17: note: in expansion of macro 'pr_err'
>   506 |                 pr_err("Unexpected call sequence at %p: %s %s\n",
>       |                 ^~~~~~
> ./arch/powerpc/include/asm/inst.h:156:14: note: '__str' declared here
>   156 |         char __str[PPC_INST_STR_LEN];   \
>       |              ^~~~~
> ./include/linux/printk.h:418:33: note: in expansion of macro 'ppc_inst_as_str'
>   418 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
>       |                                 ^~~~~~~~~~~
> ./include/linux/printk.h:446:26: note: in expansion of macro 'printk_index_wrap'
>   446 | #define printk(fmt, ...) printk_index_wrap(_printk, 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:506:17: note: in expansion of macro 'pr_err'
>   506 |                 pr_err("Unexpected call sequence at %p: %s %s\n",
>       |                 ^~~~~~
> cc1: all warnings being treated as errors
> make[3]: *** [scripts/Makefile.build:288: arch/powerpc/kernel/trace/ftrace.o] Error 1
> 
> I also hit this error on current master (commit babf0bb978e3c9
> ("Merge tag 'xfs-5.19-for-linus' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux")).
> 
> Thanks.
> 
> Reported-by: Bagas Sanjaya <bagasdotme@gmail.com>
> 
> -- 
> An old man doll... just what I always wanted! - Clara

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: dangling pointer to '__str' error on ppc64_defconfig, GCC 12.1.0
  2022-05-26 13:19   ` Petr Mladek
@ 2022-05-30 10:53     ` Michael Ellerman
  -1 siblings, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2022-05-30 10:53 UTC (permalink / raw)
  To: Petr Mladek, Bagas Sanjaya
  Cc: linuxppc-dev, linux-kernel, Sergey Senozhatsky, Steven Rostedt,
	John Ogness, Benjamin Herrenschmidt, Paul Mackerras,
	David Howells, Jordan Niethe

Petr Mladek <pmladek@suse.com> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: dangling pointer to '__str' error on ppc64_defconfig, GCC 12.1.0
@ 2022-05-30 10:53     ` Michael Ellerman
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2022-05-30 10:53 UTC (permalink / raw)
  To: Petr Mladek, Bagas Sanjaya
  Cc: John Ogness, linux-kernel, Steven Rostedt, David Howells,
	Sergey Senozhatsky, Paul Mackerras, Jordan Niethe, linuxppc-dev

Petr Mladek <pmladek@suse.com> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-05-30 10:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-26  9:17 dangling pointer to '__str' error on ppc64_defconfig, GCC 12.1.0 Bagas Sanjaya
2022-05-26  9:17 ` Bagas Sanjaya
2022-05-26 13:19 ` Petr Mladek
2022-05-26 13:19   ` Petr Mladek
2022-05-30 10:53   ` Michael Ellerman
2022-05-30 10:53     ` Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.