Skip to content

Commit 4ed8f33

Browse files
committed
Revert "tracing: Add "(fault)" name injection to kernel probes"
This reverts commit 2e9906f. It was turned out that commit 2e9906f ("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>
1 parent e38e2c6 commit 4ed8f33

File tree

3 files changed

+9
-26
lines changed

3 files changed

+9
-26
lines changed

kernel/trace/trace.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ enum trace_type {
113113
#define MEM_FAIL(condition, fmt, ...) \
114114
DO_ONCE_LITE_IF(condition, pr_err, "ERROR: " fmt, ##__VA_ARGS__)
115115

116+
#define FAULT_STRING "(fault)"
117+
116118
#define HIST_STACKTRACE_DEPTH 16
117119
#define HIST_STACKTRACE_SIZE (HIST_STACKTRACE_DEPTH * sizeof(unsigned long))
118120
#define HIST_STACKTRACE_SKIP 5

kernel/trace/trace_probe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ int PRINT_TYPE_FUNC_NAME(string)(struct trace_seq *s, void *data, void *ent)
6565
int len = *(u32 *)data >> 16;
6666

6767
if (!len)
68-
trace_seq_puts(s, "(fault)");
68+
trace_seq_puts(s, FAULT_STRING);
6969
else
7070
trace_seq_printf(s, "\"%s\"",
7171
(const char *)get_loc_data(data, ent));

kernel/trace/trace_probe_kernel.h

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
#ifndef __TRACE_PROBE_KERNEL_H_
33
#define __TRACE_PROBE_KERNEL_H_
44

5-
#define FAULT_STRING "(fault)"
6-
75
/*
86
* This depends on trace_probe.h, but can not include it due to
97
* the way trace_probe_tmpl.h is used by trace_kprobe.c and trace_eprobe.c.
@@ -15,16 +13,8 @@ static nokprobe_inline int
1513
fetch_store_strlen_user(unsigned long addr)
1614
{
1715
const void __user *uaddr = (__force const void __user *)addr;
18-
int ret;
1916

20-
ret = strnlen_user_nofault(uaddr, MAX_STRING_SIZE);
21-
/*
22-
* strnlen_user_nofault returns zero on fault, insert the
23-
* FAULT_STRING when that occurs.
24-
*/
25-
if (ret <= 0)
26-
return strlen(FAULT_STRING) + 1;
27-
return ret;
17+
return strnlen_user_nofault(uaddr, MAX_STRING_SIZE);
2818
}
2919

3020
/* Return the length of string -- including null terminal byte */
@@ -44,18 +34,7 @@ fetch_store_strlen(unsigned long addr)
4434
len++;
4535
} while (c && ret == 0 && len < MAX_STRING_SIZE);
4636

47-
/* For faults, return enough to hold the FAULT_STRING */
48-
return (ret < 0) ? strlen(FAULT_STRING) + 1 : len;
49-
}
50-
51-
static nokprobe_inline void set_data_loc(int ret, void *dest, void *__dest, void *base, int len)
52-
{
53-
if (ret >= 0) {
54-
*(u32 *)dest = make_data_loc(ret, __dest - base);
55-
} else {
56-
strscpy(__dest, FAULT_STRING, len);
57-
ret = strlen(__dest) + 1;
58-
}
37+
return (ret < 0) ? ret : len;
5938
}
6039

6140
/*
@@ -76,7 +55,8 @@ fetch_store_string_user(unsigned long addr, void *dest, void *base)
7655
__dest = get_loc_data(dest, base);
7756

7857
ret = strncpy_from_user_nofault(__dest, uaddr, maxlen);
79-
set_data_loc(ret, dest, __dest, base, maxlen);
58+
if (ret >= 0)
59+
*(u32 *)dest = make_data_loc(ret, __dest - base);
8060

8161
return ret;
8262
}
@@ -107,7 +87,8 @@ fetch_store_string(unsigned long addr, void *dest, void *base)
10787
* probing.
10888
*/
10989
ret = strncpy_from_kernel_nofault(__dest, (void *)addr, maxlen);
110-
set_data_loc(ret, dest, __dest, base, maxlen);
90+
if (ret >= 0)
91+
*(u32 *)dest = make_data_loc(ret, __dest - base);
11192

11293
return ret;
11394
}

0 commit comments

Comments
 (0)