aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_kprobe.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/trace/trace_kprobe.c')
-rw-r--r--kernel/trace/trace_kprobe.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 0c4f00aafb9..6d488efd16b 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -32,7 +32,7 @@
32#include "trace.h" 32#include "trace.h"
33#include "trace_output.h" 33#include "trace_output.h"
34 34
35#define TRACE_KPROBE_ARGS 6 35#define MAX_TRACE_ARGS 128
36#define MAX_ARGSTR_LEN 63 36#define MAX_ARGSTR_LEN 63
37 37
38/* currently, trace_kprobe only supports X86. */ 38/* currently, trace_kprobe only supports X86. */
@@ -184,11 +184,15 @@ struct trace_probe {
184 struct kretprobe rp; 184 struct kretprobe rp;
185 }; 185 };
186 const char *symbol; /* symbol name */ 186 const char *symbol; /* symbol name */
187 unsigned int nr_args;
188 struct fetch_func args[TRACE_KPROBE_ARGS];
189 struct ftrace_event_call call; 187 struct ftrace_event_call call;
188 unsigned int nr_args;
189 struct fetch_func args[];
190}; 190};
191 191
192#define SIZEOF_TRACE_PROBE(n) \
193 (offsetof(struct trace_probe, args) + \
194 (sizeof(struct fetch_func) * (n)))
195
192static int kprobe_trace_func(struct kprobe *kp, struct pt_regs *regs); 196static int kprobe_trace_func(struct kprobe *kp, struct pt_regs *regs);
193static int kretprobe_trace_func(struct kretprobe_instance *ri, 197static int kretprobe_trace_func(struct kretprobe_instance *ri,
194 struct pt_regs *regs); 198 struct pt_regs *regs);
@@ -263,11 +267,11 @@ static DEFINE_MUTEX(probe_lock);
263static LIST_HEAD(probe_list); 267static LIST_HEAD(probe_list);
264 268
265static struct trace_probe *alloc_trace_probe(const char *symbol, 269static struct trace_probe *alloc_trace_probe(const char *symbol,
266 const char *event) 270 const char *event, int nargs)
267{ 271{
268 struct trace_probe *tp; 272 struct trace_probe *tp;
269 273
270 tp = kzalloc(sizeof(struct trace_probe), GFP_KERNEL); 274 tp = kzalloc(SIZEOF_TRACE_PROBE(nargs), GFP_KERNEL);
271 if (!tp) 275 if (!tp)
272 return ERR_PTR(-ENOMEM); 276 return ERR_PTR(-ENOMEM);
273 277
@@ -573,9 +577,10 @@ static int create_trace_probe(int argc, char **argv)
573 if (offset && is_return) 577 if (offset && is_return)
574 return -EINVAL; 578 return -EINVAL;
575 } 579 }
580 argc -= 2; argv += 2;
576 581
577 /* setup a probe */ 582 /* setup a probe */
578 tp = alloc_trace_probe(symbol, event); 583 tp = alloc_trace_probe(symbol, event, argc);
579 if (IS_ERR(tp)) 584 if (IS_ERR(tp))
580 return PTR_ERR(tp); 585 return PTR_ERR(tp);
581 586
@@ -594,8 +599,8 @@ static int create_trace_probe(int argc, char **argv)
594 kp->addr = addr; 599 kp->addr = addr;
595 600
596 /* parse arguments */ 601 /* parse arguments */
597 argc -= 2; argv += 2; ret = 0; 602 ret = 0;
598 for (i = 0; i < argc && i < TRACE_KPROBE_ARGS; i++) { 603 for (i = 0; i < argc && i < MAX_TRACE_ARGS; i++) {
599 if (strlen(argv[i]) > MAX_ARGSTR_LEN) { 604 if (strlen(argv[i]) > MAX_ARGSTR_LEN) {
600 pr_info("Argument%d(%s) is too long.\n", i, argv[i]); 605 pr_info("Argument%d(%s) is too long.\n", i, argv[i]);
601 ret = -ENOSPC; 606 ret = -ENOSPC;