From 76383a70d778c2e27a96720b2140ee847943548b Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 11 Aug 2020 18:30:08 +0200 Subject: [PATCH] 5.7-stable patches added patches: tracepoint-mark-__tracepoint_string-s-__used.patch --- ...nt-mark-__tracepoint_string-s-__used.patch | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 queue-5.7/tracepoint-mark-__tracepoint_string-s-__used.patch diff --git a/queue-5.7/tracepoint-mark-__tracepoint_string-s-__used.patch b/queue-5.7/tracepoint-mark-__tracepoint_string-s-__used.patch new file mode 100644 index 00000000000..47fad7b6464 --- /dev/null +++ b/queue-5.7/tracepoint-mark-__tracepoint_string-s-__used.patch @@ -0,0 +1,50 @@ +From f3751ad0116fb6881f2c3c957d66a9327f69cefb Mon Sep 17 00:00:00 2001 +From: Nick Desaulniers +Date: Thu, 30 Jul 2020 15:45:54 -0700 +Subject: tracepoint: Mark __tracepoint_string's __used + +From: Nick Desaulniers + +commit f3751ad0116fb6881f2c3c957d66a9327f69cefb upstream. + +__tracepoint_string's have their string data stored in .rodata, and an +address to that data stored in the "__tracepoint_str" section. Functions +that refer to those strings refer to the symbol of the address. Compiler +optimization can replace those address references with references +directly to the string data. If the address doesn't appear to have other +uses, then it appears dead to the compiler and is removed. This can +break the /tracing/printk_formats sysfs node which iterates the +addresses stored in the "__tracepoint_str" section. + +Like other strings stored in custom sections in this header, mark these +__used to inform the compiler that there are other non-obvious users of +the address, so they should still be emitted. + +Link: https://lkml.kernel.org/r/20200730224555.2142154-2-ndesaulniers@google.com + +Cc: Ingo Molnar +Cc: Miguel Ojeda +Cc: stable@vger.kernel.org +Fixes: 102c9323c35a8 ("tracing: Add __tracepoint_string() to export string pointers") +Reported-by: Tim Murray +Reported-by: Simon MacMullen +Suggested-by: Greg Hackmann +Signed-off-by: Nick Desaulniers +Signed-off-by: Steven Rostedt (VMware) +Signed-off-by: Greg Kroah-Hartman + +--- + include/linux/tracepoint.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/include/linux/tracepoint.h ++++ b/include/linux/tracepoint.h +@@ -361,7 +361,7 @@ static inline struct tracepoint *tracepo + static const char *___tp_str __tracepoint_string = str; \ + ___tp_str; \ + }) +-#define __tracepoint_string __attribute__((section("__tracepoint_str"))) ++#define __tracepoint_string __attribute__((section("__tracepoint_str"), used)) + #else + /* + * tracepoint_string() is used to save the string address for userspace -- 2.47.3