* /tmp/perf-PID.map ownership
@ 2015-11-12 18:27 Brendan Gregg
2015-11-12 18:52 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 6+ messages in thread
From: Brendan Gregg @ 2015-11-12 18:27 UTC (permalink / raw)
To: linux-perf-use.
G'Day,
# perf record -F 99 -a -g -- sleep 30
[...]
# perf report -n --stdio
File /tmp/perf-25958.map not owned by current user or root, ignoring it.
Can root bypass this test? I'm root, and profiling apps from different
user-IDs, and the current workaround is to "chown root
/tmp/perf*.map". Shouldn't root be able to read these map files? Could
we:
--- linux-perf/tools/perf/util/symbol.c 2015-11-03 20:08:40.829320940 +0000
+++ linux-perf-edited/tools/perf/util/symbol.c 2015-11-12
18:21:35.487077872 +0000
@@ -1433,14 +1433,17 @@
dso->adjust_symbols = 0;
if (strncmp(dso->name, "/tmp/perf-", 10) == 0) {
+ uint_t euid;
struct stat st;
if (lstat(dso->name, &st) < 0)
goto out;
- if (st.st_uid && (st.st_uid != geteuid())) {
- pr_warning("File %s not owned by current user or root, "
- "ignoring it.\n", dso->name);
+ euid = geteuid();
+ if (euid && st.st_uid && (st.st_uid != euid)) {
+ pr_warning("File %s not owned by current user, and "
+ "current user is not root. Ignoring it.\n",
+ dso->name);
goto out;
}
Brendan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: /tmp/perf-PID.map ownership
2015-11-12 18:27 /tmp/perf-PID.map ownership Brendan Gregg
@ 2015-11-12 18:52 ` Arnaldo Carvalho de Melo
2015-11-12 18:59 ` Brendan Gregg
0 siblings, 1 reply; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-11-12 18:52 UTC (permalink / raw)
To: Brendan Gregg; +Cc: linux-perf-use.
Em Thu, Nov 12, 2015 at 10:27:26AM -0800, Brendan Gregg escreveu:
> G'Day,
>
> # perf record -F 99 -a -g -- sleep 30
> [...]
> # perf report -n --stdio
> File /tmp/perf-25958.map not owned by current user or root, ignoring it.
>
> Can root bypass this test? I'm root, and profiling apps from different
In other places such tests are overridable via '-f' (force), this one
should too, I think.
# perf report
File perf.data not owned by current user or root (use -f to override)
[root@zoo linux]# ls -la perf.data
-rw-------. 1 acme acme 20032 Nov 12 15:50 perf.data
- Arnaldo
> user-IDs, and the current workaround is to "chown root
> /tmp/perf*.map". Shouldn't root be able to read these map files? Could
> we:
>
> --- linux-perf/tools/perf/util/symbol.c 2015-11-03 20:08:40.829320940 +0000
> +++ linux-perf-edited/tools/perf/util/symbol.c 2015-11-12
> 18:21:35.487077872 +0000
> @@ -1433,14 +1433,17 @@
> dso->adjust_symbols = 0;
>
> if (strncmp(dso->name, "/tmp/perf-", 10) == 0) {
> + uint_t euid;
> struct stat st;
>
> if (lstat(dso->name, &st) < 0)
> goto out;
>
> - if (st.st_uid && (st.st_uid != geteuid())) {
> - pr_warning("File %s not owned by current user or root, "
> - "ignoring it.\n", dso->name);
> + euid = geteuid();
> + if (euid && st.st_uid && (st.st_uid != euid)) {
> + pr_warning("File %s not owned by current user, and "
> + "current user is not root. Ignoring it.\n",
> + dso->name);
> goto out;
> }
>
> Brendan
> --
> To unsubscribe from this list: send the line "unsubscribe linux-perf-users" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: /tmp/perf-PID.map ownership
2015-11-12 18:52 ` Arnaldo Carvalho de Melo
@ 2015-11-12 18:59 ` Brendan Gregg
2015-11-12 19:04 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 6+ messages in thread
From: Brendan Gregg @ 2015-11-12 18:59 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: linux-perf-use.
On Thu, Nov 12, 2015 at 10:52 AM, Arnaldo Carvalho de Melo
<arnaldo.melo@gmail.com> wrote:
> Em Thu, Nov 12, 2015 at 10:27:26AM -0800, Brendan Gregg escreveu:
>> G'Day,
>>
>> # perf record -F 99 -a -g -- sleep 30
>> [...]
>> # perf report -n --stdio
>> File /tmp/perf-25958.map not owned by current user or root, ignoring it.
>>
>> Can root bypass this test? I'm root, and profiling apps from different
>
> In other places such tests are overridable via '-f' (force), this one
> should too, I think.
>
> # perf report
> File perf.data not owned by current user or root (use -f to override)
> [root@zoo linux]# ls -la perf.data
> -rw-------. 1 acme acme 20032 Nov 12 15:50 perf.data
Yes, a -f option would work too...
Brendan
>
> - Arnaldo
>
>> user-IDs, and the current workaround is to "chown root
>> /tmp/perf*.map". Shouldn't root be able to read these map files? Could
>> we:
>>
>> --- linux-perf/tools/perf/util/symbol.c 2015-11-03 20:08:40.829320940 +0000
>> +++ linux-perf-edited/tools/perf/util/symbol.c 2015-11-12
>> 18:21:35.487077872 +0000
>> @@ -1433,14 +1433,17 @@
>> dso->adjust_symbols = 0;
>>
>> if (strncmp(dso->name, "/tmp/perf-", 10) == 0) {
>> + uint_t euid;
>> struct stat st;
>>
>> if (lstat(dso->name, &st) < 0)
>> goto out;
>>
>> - if (st.st_uid && (st.st_uid != geteuid())) {
>> - pr_warning("File %s not owned by current user or root, "
>> - "ignoring it.\n", dso->name);
>> + euid = geteuid();
>> + if (euid && st.st_uid && (st.st_uid != euid)) {
>> + pr_warning("File %s not owned by current user, and "
>> + "current user is not root. Ignoring it.\n",
>> + dso->name);
>> goto out;
>> }
>>
>> Brendan
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-perf-users" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: /tmp/perf-PID.map ownership
2015-11-12 18:59 ` Brendan Gregg
@ 2015-11-12 19:04 ` Arnaldo Carvalho de Melo
2015-11-12 19:49 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-11-12 19:04 UTC (permalink / raw)
To: Brendan Gregg; +Cc: linux-perf-use.
Em Thu, Nov 12, 2015 at 10:59:36AM -0800, Brendan Gregg escreveu:
> On Thu, Nov 12, 2015 at 10:52 AM, Arnaldo Carvalho de Melo
> <arnaldo.melo@gmail.com> wrote:
> > Em Thu, Nov 12, 2015 at 10:27:26AM -0800, Brendan Gregg escreveu:
> >> G'Day,
> >>
> >> # perf record -F 99 -a -g -- sleep 30
> >> [...]
> >> # perf report -n --stdio
> >> File /tmp/perf-25958.map not owned by current user or root, ignoring it.
> >>
> >> Can root bypass this test? I'm root, and profiling apps from different
> >
> > In other places such tests are overridable via '-f' (force), this one
> > should too, I think.
> >
> > # perf report
> > File perf.data not owned by current user or root (use -f to override)
> > [root@zoo linux]# ls -la perf.data
> > -rw-------. 1 acme acme 20032 Nov 12 15:50 perf.data
>
> Yes, a -f option would work too...
Cooking up a patch right now.
- Arnaldo
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: /tmp/perf-PID.map ownership
2015-11-12 19:04 ` Arnaldo Carvalho de Melo
@ 2015-11-12 19:49 ` Arnaldo Carvalho de Melo
2015-11-12 20:01 ` Brendan Gregg
0 siblings, 1 reply; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-11-12 19:49 UTC (permalink / raw)
To: Brendan Gregg; +Cc: linux-perf-use.
Em Thu, Nov 12, 2015 at 04:04:44PM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Thu, Nov 12, 2015 at 10:59:36AM -0800, Brendan Gregg escreveu:
> > On Thu, Nov 12, 2015 at 10:52 AM, Arnaldo Carvalho de Melo
> > <arnaldo.melo@gmail.com> wrote:
> > > Em Thu, Nov 12, 2015 at 10:27:26AM -0800, Brendan Gregg escreveu:
> > >> G'Day,
> > >>
> > >> # perf record -F 99 -a -g -- sleep 30
> > >> [...]
> > >> # perf report -n --stdio
> > >> File /tmp/perf-25958.map not owned by current user or root, ignoring it.
> > >>
> > >> Can root bypass this test? I'm root, and profiling apps from different
> > >
> > > In other places such tests are overridable via '-f' (force), this one
> > > should too, I think.
> > >
> > > # perf report
> > > File perf.data not owned by current user or root (use -f to override)
> > > [root@zoo linux]# ls -la perf.data
> > > -rw-------. 1 acme acme 20032 Nov 12 15:50 perf.data
> >
> > Yes, a -f option would work too...
>
> Cooking up a patch right now.
This way it gets consistent with the other checks, please let me know if
I can have your Tested-by, checking other places where this check is
done to make it follow this rule too.
- Arnaldo
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 2853ad2bd435..f256fac1e722 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -44,7 +44,7 @@
struct report {
struct perf_tool tool;
struct perf_session *session;
- bool force, use_tui, use_gtk, use_stdio;
+ bool use_tui, use_gtk, use_stdio;
bool hide_unresolved;
bool dont_use_callchains;
bool show_full_info;
@@ -678,7 +678,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
"file", "vmlinux pathname"),
OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name,
"file", "kallsyms pathname"),
- OPT_BOOLEAN('f', "force", &report.force, "don't complain, do it"),
+ OPT_BOOLEAN('f', "force", &symbol_conf.force, "don't complain, do it"),
OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules,
"load module symbols - WARNING: use only with -k and LIVE kernel"),
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)
}
file.path = input_name;
- file.force = report.force;
+ file.force = symbol_conf.force;
repeat:
session = perf_session__new(&file, false, &report.tool);
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 09343a880c0b..cd08027a6d2c 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1436,9 +1436,9 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
if (lstat(dso->name, &st) < 0)
goto out;
- if (st.st_uid && (st.st_uid != geteuid())) {
+ if (!symbol_conf.force && st.st_uid && (st.st_uid != geteuid())) {
pr_warning("File %s not owned by current user or root, "
- "ignoring it.\n", dso->name);
+ "ignoring it (use -f to override).\n", dso->name);
goto out;
}
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 40073c60b83d..dcd786e364f2 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -84,6 +84,7 @@ struct symbol_conf {
unsigned short priv_size;
unsigned short nr_events;
bool try_vmlinux_path,
+ force,
ignore_vmlinux,
ignore_vmlinux_buildid,
show_kernel_path,
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: /tmp/perf-PID.map ownership
2015-11-12 19:49 ` Arnaldo Carvalho de Melo
@ 2015-11-12 20:01 ` Brendan Gregg
0 siblings, 0 replies; 6+ messages in thread
From: Brendan Gregg @ 2015-11-12 20:01 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: linux-perf-use.
On Thu, Nov 12, 2015 at 11:49 AM, Arnaldo Carvalho de Melo
<arnaldo.melo@gmail.com> wrote:
> Em Thu, Nov 12, 2015 at 04:04:44PM -0300, Arnaldo Carvalho de Melo escreveu:
>> Em Thu, Nov 12, 2015 at 10:59:36AM -0800, Brendan Gregg escreveu:
>> > On Thu, Nov 12, 2015 at 10:52 AM, Arnaldo Carvalho de Melo
>> > <arnaldo.melo@gmail.com> wrote:
>> > > Em Thu, Nov 12, 2015 at 10:27:26AM -0800, Brendan Gregg escreveu:
>> > >> G'Day,
>> > >>
>> > >> # perf record -F 99 -a -g -- sleep 30
>> > >> [...]
>> > >> # perf report -n --stdio
>> > >> File /tmp/perf-25958.map not owned by current user or root, ignoring it.
>> > >>
>> > >> Can root bypass this test? I'm root, and profiling apps from different
>> > >
>> > > In other places such tests are overridable via '-f' (force), this one
>> > > should too, I think.
>> > >
>> > > # perf report
>> > > File perf.data not owned by current user or root (use -f to override)
>> > > [root@zoo linux]# ls -la perf.data
>> > > -rw-------. 1 acme acme 20032 Nov 12 15:50 perf.data
>> >
>> > Yes, a -f option would work too...
>>
>> Cooking up a patch right now.
>
> This way it gets consistent with the other checks, please let me know if
> I can have your Tested-by, checking other places where this check is
> done to make it follow this rule too.
Tested, it works, thanks!
Brendan
>
> - Arnaldo
>
> diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
> index 2853ad2bd435..f256fac1e722 100644
> --- a/tools/perf/builtin-report.c
> +++ b/tools/perf/builtin-report.c
> @@ -44,7 +44,7 @@
> struct report {
> struct perf_tool tool;
> struct perf_session *session;
> - bool force, use_tui, use_gtk, use_stdio;
> + bool use_tui, use_gtk, use_stdio;
> bool hide_unresolved;
> bool dont_use_callchains;
> bool show_full_info;
> @@ -678,7 +678,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
> "file", "vmlinux pathname"),
> OPT_STRING(0, "kallsyms", &symbol_conf.kallsyms_name,
> "file", "kallsyms pathname"),
> - OPT_BOOLEAN('f', "force", &report.force, "don't complain, do it"),
> + OPT_BOOLEAN('f', "force", &symbol_conf.force, "don't complain, do it"),
> OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules,
> "load module symbols - WARNING: use only with -k and LIVE kernel"),
> 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)
> }
>
> file.path = input_name;
> - file.force = report.force;
> + file.force = symbol_conf.force;
>
> repeat:
> session = perf_session__new(&file, false, &report.tool);
> diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
> index 09343a880c0b..cd08027a6d2c 100644
> --- a/tools/perf/util/symbol.c
> +++ b/tools/perf/util/symbol.c
> @@ -1436,9 +1436,9 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter)
> if (lstat(dso->name, &st) < 0)
> goto out;
>
> - if (st.st_uid && (st.st_uid != geteuid())) {
> + if (!symbol_conf.force && st.st_uid && (st.st_uid != geteuid())) {
> pr_warning("File %s not owned by current user or root, "
> - "ignoring it.\n", dso->name);
> + "ignoring it (use -f to override).\n", dso->name);
> goto out;
> }
>
> diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
> index 40073c60b83d..dcd786e364f2 100644
> --- a/tools/perf/util/symbol.h
> +++ b/tools/perf/util/symbol.h
> @@ -84,6 +84,7 @@ struct symbol_conf {
> unsigned short priv_size;
> unsigned short nr_events;
> bool try_vmlinux_path,
> + force,
> ignore_vmlinux,
> ignore_vmlinux_buildid,
> show_kernel_path,
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-11-12 20:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-12 18:27 /tmp/perf-PID.map ownership Brendan Gregg
2015-11-12 18:52 ` Arnaldo Carvalho de Melo
2015-11-12 18:59 ` Brendan Gregg
2015-11-12 19:04 ` Arnaldo Carvalho de Melo
2015-11-12 19:49 ` Arnaldo Carvalho de Melo
2015-11-12 20:01 ` Brendan Gregg
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.