Skip to content

Commit 2059fc7

Browse files
committed
perf symbols: Allow forcing reading of non-root owned files by root
When the root user tries to read a file owned by some other user we get: # ls -la perf.data -rw-------. 1 acme acme 20032 Nov 12 15:50 perf.data # perf report File perf.data not owned by current user or root (use -f to override) # perf report -f | grep -v ^# | head -2 30.96% ls [kernel.vmlinux] [k] do_set_pte 28.24% ls libc-2.20.so [.] intel_check_word # That wasn't happening when the symbol code tried to read a JIT map, where the same check was done but no forcing was possible, fix it. Reported-by: Brendan Gregg <[email protected]> Tested-by: Brendan Gregg <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: David Ahern <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Wang Nan <[email protected]> Link: http://permalink.gmane.org/gmane.linux.kernel.perf.user/2380 Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent b7f294b commit 2059fc7

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

tools/perf/builtin-report.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
struct report {
4545
struct perf_tool tool;
4646
struct perf_session *session;
47-
bool force, use_tui, use_gtk, use_stdio;
47+
bool use_tui, use_gtk, use_stdio;
4848
bool hide_unresolved;
4949
bool dont_use_callchains;
5050
bool show_full_info;
@@ -678,7 +678,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
678678
"file", "vmlinux pathname"),
679679
OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name,
680680
"file", "kallsyms pathname"),
681-
OPT_BOOLEAN('f', "force", &report.force, "don't complain, do it"),
681+
OPT_BOOLEAN('f', "force", &symbol_conf.force, "don't complain, do it"),
682682
OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules,
683683
"load module symbols - WARNING: use only with -k and LIVE kernel"),
684684
OPT_BOOLEAN('n', "show-nr-samples", &symbol_conf.show_nr_samples,
@@ -832,7 +832,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
832832
}
833833

834834
file.path = input_name;
835-
file.force = report.force;
835+
file.force = symbol_conf.force;
836836

837837
repeat:
838838
session = perf_session__new(&file, false, &report.tool);

tools/perf/util/symbol.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,9 +1436,9 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
14361436
if (lstat(dso->name, &st) < 0)
14371437
goto out;
14381438

1439-
if (st.st_uid && (st.st_uid != geteuid())) {
1439+
if (!symbol_conf.force && st.st_uid && (st.st_uid != geteuid())) {
14401440
pr_warning("File %s not owned by current user or root, "
1441-
"ignoring it.\n", dso->name);
1441+
"ignoring it (use -f to override).\n", dso->name);
14421442
goto out;
14431443
}
14441444

tools/perf/util/symbol.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ struct symbol_conf {
8484
unsigned short priv_size;
8585
unsigned short nr_events;
8686
bool try_vmlinux_path,
87+
force,
8788
ignore_vmlinux,
8889
ignore_vmlinux_buildid,
8990
show_kernel_path,

0 commit comments

Comments
 (0)