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.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 72d0c65c8676..aff5f80b59b8 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -483,7 +483,8 @@ static int parse_probe_vars(char *arg, struct fetch_func *ff, int is_return)
483 return ret; 483 return ret;
484} 484}
485 485
486static int parse_probe_arg(char *arg, struct fetch_func *ff, int is_return) 486/* Recursive argument parser */
487static int __parse_probe_arg(char *arg, struct fetch_func *ff, int is_return)
487{ 488{
488 int ret = 0; 489 int ret = 0;
489 unsigned long param; 490 unsigned long param;
@@ -543,7 +544,7 @@ static int parse_probe_arg(char *arg, struct fetch_func *ff, int is_return)
543 if (!id) 544 if (!id)
544 return -ENOMEM; 545 return -ENOMEM;
545 id->offset = offset; 546 id->offset = offset;
546 ret = parse_probe_arg(arg, &id->orig, is_return); 547 ret = __parse_probe_arg(arg, &id->orig, is_return);
547 if (ret) 548 if (ret)
548 kfree(id); 549 kfree(id);
549 else { 550 else {
@@ -560,6 +561,16 @@ static int parse_probe_arg(char *arg, struct fetch_func *ff, int is_return)
560 return ret; 561 return ret;
561} 562}
562 563
564/* String length checking wrapper */
565static int parse_probe_arg(char *arg, struct fetch_func *ff, int is_return)
566{
567 if (strlen(arg) > MAX_ARGSTR_LEN) {
568 pr_info("Argument is too long.: %s\n", arg);
569 return -ENOSPC;
570 }
571 return __parse_probe_arg(arg, ff, is_return);
572}
573
563/* Return 1 if name is reserved or already used by another argument */ 574/* Return 1 if name is reserved or already used by another argument */
564static int conflict_field_name(const char *name, 575static int conflict_field_name(const char *name,
565 struct probe_arg *args, int narg) 576 struct probe_arg *args, int narg)
@@ -698,13 +709,14 @@ static int create_trace_probe(int argc, char **argv)
698 } 709 }
699 710
700 tp->args[i].name = kstrdup(argv[i], GFP_KERNEL); 711 tp->args[i].name = kstrdup(argv[i], GFP_KERNEL);
701 712 if (!tp->args[i].name) {
702 /* Parse fetch argument */ 713 pr_info("Failed to allocate argument%d name '%s'.\n",
703 if (strlen(arg) > MAX_ARGSTR_LEN) { 714 i, argv[i]);
704 pr_info("Argument%d(%s) is too long.\n", i, arg); 715 ret = -ENOMEM;
705 ret = -ENOSPC;
706 goto error; 716 goto error;
707 } 717 }
718
719 /* Parse fetch argument */
708 ret = parse_probe_arg(arg, &tp->args[i].fetch, is_return); 720 ret = parse_probe_arg(arg, &tp->args[i].fetch, is_return);
709 if (ret) { 721 if (ret) {
710 pr_info("Parse error at argument%d. (%d)\n", i, ret); 722 pr_info("Parse error at argument%d. (%d)\n", i, ret);