Skip to content

Commit 7cc7255

Browse files
James-A-Clarkacmel
authored andcommitted
perf tools: Check vmlinux/kallsyms arguments in all tools
Only perf report checked the validity of these arguments so apply the same check to all tools that read them for consistency. Signed-off-by: James Clark <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Denis Nikitin <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent a3df50a commit 7cc7255

File tree

7 files changed

+28
-0
lines changed

7 files changed

+28
-0
lines changed

tools/perf/builtin-annotate.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,10 @@ int cmd_annotate(int argc, const char **argv)
591591
return ret;
592592
}
593593

594+
ret = symbol__validate_sym_arguments();
595+
if (ret)
596+
return ret;
597+
594598
if (quiet)
595599
perf_quiet_option();
596600

tools/perf/builtin-c2c.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2768,6 +2768,10 @@ static int perf_c2c__report(int argc, const char **argv)
27682768
if (c2c.stats_only)
27692769
c2c.use_stdio = true;
27702770

2771+
err = symbol__validate_sym_arguments();
2772+
if (err)
2773+
goto out;
2774+
27712775
if (!input_name || !strlen(input_name))
27722776
input_name = "perf.data";
27732777

tools/perf/builtin-probe.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "util/build-id.h"
2222
#include "util/strlist.h"
2323
#include "util/strfilter.h"
24+
#include "util/symbol.h"
2425
#include "util/symbol_conf.h"
2526
#include "util/debug.h"
2627
#include <subcmd/parse-options.h>
@@ -629,6 +630,10 @@ __cmd_probe(int argc, const char **argv)
629630
params.command = 'a';
630631
}
631632

633+
ret = symbol__validate_sym_arguments();
634+
if (ret)
635+
return ret;
636+
632637
if (params.quiet) {
633638
if (verbose != 0) {
634639
pr_err(" Error: -v and -q are exclusive.\n");

tools/perf/builtin-record.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2712,6 +2712,10 @@ int cmd_record(int argc, const char **argv)
27122712
if (quiet)
27132713
perf_quiet_option();
27142714

2715+
err = symbol__validate_sym_arguments();
2716+
if (err)
2717+
return err;
2718+
27152719
/* Make system wide (-a) the default target. */
27162720
if (!argc && target__none(&rec->opts.target))
27172721
rec->opts.target.system_wide = true;

tools/perf/builtin-sched.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3538,6 +3538,7 @@ int cmd_sched(int argc, const char **argv)
35383538
.fork_event = replay_fork_event,
35393539
};
35403540
unsigned int i;
3541+
int ret;
35413542

35423543
for (i = 0; i < ARRAY_SIZE(sched.curr_pid); i++)
35433544
sched.curr_pid[i] = -1;
@@ -3598,6 +3599,9 @@ int cmd_sched(int argc, const char **argv)
35983599
parse_options_usage(NULL, timehist_options, "n", true);
35993600
return -EINVAL;
36003601
}
3602+
ret = symbol__validate_sym_arguments();
3603+
if (ret)
3604+
return ret;
36013605

36023606
return perf_sched__timehist(&sched);
36033607
} else {

tools/perf/builtin-script.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3846,6 +3846,9 @@ int cmd_script(int argc, const char **argv)
38463846
data.path = input_name;
38473847
data.force = symbol_conf.force;
38483848

3849+
if (symbol__validate_sym_arguments())
3850+
return -1;
3851+
38493852
if (argc > 1 && !strncmp(argv[0], "rec", strlen("rec"))) {
38503853
rec_script_path = get_script_path(argv[1], RECORD_SUFFIX);
38513854
if (!rec_script_path)

tools/perf/builtin-top.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,6 +1618,10 @@ int cmd_top(int argc, const char **argv)
16181618
if (argc)
16191619
usage_with_options(top_usage, options);
16201620

1621+
status = symbol__validate_sym_arguments();
1622+
if (status)
1623+
goto out_delete_evlist;
1624+
16211625
if (annotate_check_args(&top.annotation_opts) < 0)
16221626
goto out_delete_evlist;
16231627

0 commit comments

Comments
 (0)