Revert "tracing: Add "(fault)" name injection to kernel probes"

This reverts commit 2e9906f84fc7c99388bb7123ade167250d50f1c0.

It was turned out that commit 2e9906f84fc7 ("tracing: Add "(fault)"
name injection to kernel probes") did not work correctly and probe
events still show just '(fault)' (instead of '"(fault)"'). Also,
current '(fault)' is more explicit that it faulted.

This also moves FAULT_STRING macro to trace.h so that synthetic
event can keep using it, and uses it in trace_probe.c too.

Link: https://lore.kernel.org/all/168908495772.123124.1250788051922100079.stgit@devnote2/
Link: https://lore.kernel.org/all/20230706230642.3793a593@rorschach.local.home/

Cc: stable@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Tom Zanussi <zanussi@kernel.org>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>

+9 -26
+2
kernel/trace/trace.h
··· 113 #define MEM_FAIL(condition, fmt, ...) \ 114 DO_ONCE_LITE_IF(condition, pr_err, "ERROR: " fmt, ##__VA_ARGS__) 115 116 #define HIST_STACKTRACE_DEPTH 16 117 #define HIST_STACKTRACE_SIZE (HIST_STACKTRACE_DEPTH * sizeof(unsigned long)) 118 #define HIST_STACKTRACE_SKIP 5
··· 113 #define MEM_FAIL(condition, fmt, ...) \ 114 DO_ONCE_LITE_IF(condition, pr_err, "ERROR: " fmt, ##__VA_ARGS__) 115 116 + #define FAULT_STRING "(fault)" 117 + 118 #define HIST_STACKTRACE_DEPTH 16 119 #define HIST_STACKTRACE_SIZE (HIST_STACKTRACE_DEPTH * sizeof(unsigned long)) 120 #define HIST_STACKTRACE_SKIP 5
+1 -1
kernel/trace/trace_probe.c
··· 65 int len = *(u32 *)data >> 16; 66 67 if (!len) 68 - trace_seq_puts(s, "(fault)"); 69 else 70 trace_seq_printf(s, "\"%s\"", 71 (const char *)get_loc_data(data, ent));
··· 65 int len = *(u32 *)data >> 16; 66 67 if (!len) 68 + trace_seq_puts(s, FAULT_STRING); 69 else 70 trace_seq_printf(s, "\"%s\"", 71 (const char *)get_loc_data(data, ent));
+6 -25
kernel/trace/trace_probe_kernel.h
··· 2 #ifndef __TRACE_PROBE_KERNEL_H_ 3 #define __TRACE_PROBE_KERNEL_H_ 4 5 - #define FAULT_STRING "(fault)" 6 - 7 /* 8 * This depends on trace_probe.h, but can not include it due to 9 * the way trace_probe_tmpl.h is used by trace_kprobe.c and trace_eprobe.c. ··· 13 fetch_store_strlen_user(unsigned long addr) 14 { 15 const void __user *uaddr = (__force const void __user *)addr; 16 - int ret; 17 18 - ret = strnlen_user_nofault(uaddr, MAX_STRING_SIZE); 19 - /* 20 - * strnlen_user_nofault returns zero on fault, insert the 21 - * FAULT_STRING when that occurs. 22 - */ 23 - if (ret <= 0) 24 - return strlen(FAULT_STRING) + 1; 25 - return ret; 26 } 27 28 /* Return the length of string -- including null terminal byte */ ··· 34 len++; 35 } while (c && ret == 0 && len < MAX_STRING_SIZE); 36 37 - /* For faults, return enough to hold the FAULT_STRING */ 38 - return (ret < 0) ? strlen(FAULT_STRING) + 1 : len; 39 - } 40 - 41 - static nokprobe_inline void set_data_loc(int ret, void *dest, void *__dest, void *base, int len) 42 - { 43 - if (ret >= 0) { 44 - *(u32 *)dest = make_data_loc(ret, __dest - base); 45 - } else { 46 - strscpy(__dest, FAULT_STRING, len); 47 - ret = strlen(__dest) + 1; 48 - } 49 } 50 51 /* ··· 55 __dest = get_loc_data(dest, base); 56 57 ret = strncpy_from_user_nofault(__dest, uaddr, maxlen); 58 - set_data_loc(ret, dest, __dest, base, maxlen); 59 60 return ret; 61 } ··· 87 * probing. 88 */ 89 ret = strncpy_from_kernel_nofault(__dest, (void *)addr, maxlen); 90 - set_data_loc(ret, dest, __dest, base, maxlen); 91 92 return ret; 93 }
··· 2 #ifndef __TRACE_PROBE_KERNEL_H_ 3 #define __TRACE_PROBE_KERNEL_H_ 4 5 /* 6 * This depends on trace_probe.h, but can not include it due to 7 * the way trace_probe_tmpl.h is used by trace_kprobe.c and trace_eprobe.c. ··· 15 fetch_store_strlen_user(unsigned long addr) 16 { 17 const void __user *uaddr = (__force const void __user *)addr; 18 19 + return strnlen_user_nofault(uaddr, MAX_STRING_SIZE); 20 } 21 22 /* Return the length of string -- including null terminal byte */ ··· 44 len++; 45 } while (c && ret == 0 && len < MAX_STRING_SIZE); 46 47 + return (ret < 0) ? ret : len; 48 } 49 50 /* ··· 76 __dest = get_loc_data(dest, base); 77 78 ret = strncpy_from_user_nofault(__dest, uaddr, maxlen); 79 + if (ret >= 0) 80 + *(u32 *)dest = make_data_loc(ret, __dest - base); 81 82 return ret; 83 } ··· 107 * probing. 108 */ 109 ret = strncpy_from_kernel_nofault(__dest, (void *)addr, maxlen); 110 + if (ret >= 0) 111 + *(u32 *)dest = make_data_loc(ret, __dest - base); 112 113 return ret; 114 }