]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.31/tracing-probeevent-fix-to-support-minus-offset-from-symbol.patch
Linux 4.14.124
[thirdparty/kernel/stable-queue.git] / releases / 4.14.31 / tracing-probeevent-fix-to-support-minus-offset-from-symbol.patch
1 From c5d343b6b7badd1f5fe0873eff2e8d63a193e732 Mon Sep 17 00:00:00 2001
2 From: Masami Hiramatsu <mhiramat@kernel.org>
3 Date: Sat, 17 Mar 2018 21:38:10 +0900
4 Subject: tracing: probeevent: Fix to support minus offset from symbol
5
6 From: Masami Hiramatsu <mhiramat@kernel.org>
7
8 commit c5d343b6b7badd1f5fe0873eff2e8d63a193e732 upstream.
9
10 In Documentation/trace/kprobetrace.txt, it says
11
12 @SYM[+|-offs] : Fetch memory at SYM +|- offs (SYM should be a data symbol)
13
14 However, the parser doesn't parse minus offset correctly, since
15 commit 2fba0c8867af ("tracing/kprobes: Fix probe offset to be
16 unsigned") drops minus ("-") offset support for kprobe probe
17 address usage.
18
19 This fixes the traceprobe_split_symbol_offset() to parse minus
20 offset again with checking the offset range, and add a minus
21 offset check in kprobe probe address usage.
22
23 Link: http://lkml.kernel.org/r/152129028983.31874.13419301530285775521.stgit@devbox
24
25 Cc: Ingo Molnar <mingo@redhat.com>
26 Cc: Tom Zanussi <tom.zanussi@linux.intel.com>
27 Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
28 Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
29 Cc: stable@vger.kernel.org
30 Fixes: 2fba0c8867af ("tracing/kprobes: Fix probe offset to be unsigned")
31 Acked-by: Namhyung Kim <namhyung@kernel.org>
32 Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
33 Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
34 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
35
36 ---
37 kernel/trace/trace_kprobe.c | 4 ++--
38 kernel/trace/trace_probe.c | 8 +++-----
39 kernel/trace/trace_probe.h | 2 +-
40 3 files changed, 6 insertions(+), 8 deletions(-)
41
42 --- a/kernel/trace/trace_kprobe.c
43 +++ b/kernel/trace/trace_kprobe.c
44 @@ -635,7 +635,7 @@ static int create_trace_kprobe(int argc,
45 char *symbol = NULL, *event = NULL, *group = NULL;
46 int maxactive = 0;
47 char *arg;
48 - unsigned long offset = 0;
49 + long offset = 0;
50 void *addr = NULL;
51 char buf[MAX_EVENT_NAME_LEN];
52
53 @@ -723,7 +723,7 @@ static int create_trace_kprobe(int argc,
54 symbol = argv[1];
55 /* TODO: support .init module functions */
56 ret = traceprobe_split_symbol_offset(symbol, &offset);
57 - if (ret) {
58 + if (ret || offset < 0 || offset > UINT_MAX) {
59 pr_info("Failed to parse either an address or a symbol.\n");
60 return ret;
61 }
62 --- a/kernel/trace/trace_probe.c
63 +++ b/kernel/trace/trace_probe.c
64 @@ -320,7 +320,7 @@ static fetch_func_t get_fetch_size_funct
65 }
66
67 /* Split symbol and offset. */
68 -int traceprobe_split_symbol_offset(char *symbol, unsigned long *offset)
69 +int traceprobe_split_symbol_offset(char *symbol, long *offset)
70 {
71 char *tmp;
72 int ret;
73 @@ -328,13 +328,11 @@ int traceprobe_split_symbol_offset(char
74 if (!offset)
75 return -EINVAL;
76
77 - tmp = strchr(symbol, '+');
78 + tmp = strpbrk(symbol, "+-");
79 if (tmp) {
80 - /* skip sign because kstrtoul doesn't accept '+' */
81 - ret = kstrtoul(tmp + 1, 0, offset);
82 + ret = kstrtol(tmp, 0, offset);
83 if (ret)
84 return ret;
85 -
86 *tmp = '\0';
87 } else
88 *offset = 0;
89 --- a/kernel/trace/trace_probe.h
90 +++ b/kernel/trace/trace_probe.h
91 @@ -354,7 +354,7 @@ extern int traceprobe_conflict_field_nam
92 extern void traceprobe_update_arg(struct probe_arg *arg);
93 extern void traceprobe_free_probe_arg(struct probe_arg *arg);
94
95 -extern int traceprobe_split_symbol_offset(char *symbol, unsigned long *offset);
96 +extern int traceprobe_split_symbol_offset(char *symbol, long *offset);
97
98 extern ssize_t traceprobe_probes_write(struct file *file,
99 const char __user *buffer, size_t count, loff_t *ppos,