lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-ID: <tip-46ec69add5df60310147ce3ce01a662053d82a1e@git.kernel.org> Date: Thu, 14 Aug 2014 01:45:10 -0700 From: tip-bot for Adrian Hunter <tipbot@...or.com> To: linux-tip-commits@...r.kernel.org Cc: acme@...hat.com, linux-kernel@...r.kernel.org, eranian@...gle.com, paulus@...ba.org, hpa@...or.com, mingo@...nel.org, jolsa@...nel.org, peterz@...radead.org, namhyung@...il.com, jolsa@...hat.com, fweisbec@...il.com, adrian.hunter@...el.com, dsahern@...il.com, tglx@...utronix.de Subject: [tip:perf/core] perf tools: Fix probing the kernel API with cpu-wide events Commit-ID: 46ec69add5df60310147ce3ce01a662053d82a1e Gitweb: http://git.kernel.org/tip/46ec69add5df60310147ce3ce01a662053d82a1e Author: Adrian Hunter <adrian.hunter@...el.com> AuthorDate: Tue, 12 Aug 2014 18:04:30 +0300 Committer: Arnaldo Carvalho de Melo <acme@...hat.com> CommitDate: Wed, 13 Aug 2014 16:22:06 -0300 perf tools: Fix probing the kernel API with cpu-wide events Fall back to probing with the current pid if cpu-wide probing fails. This primarily affects the setting of comm_exec flag when the user is un-privileged and /proc/sys/kernel/perf_event_paranoid > 0. The change to comm_exec can be observed by using -vv with perf record and a kernel that supports comm_exec. Signed-off-by: Adrian Hunter <adrian.hunter@...el.com> Acked-by: Jiri Olsa <jolsa@...nel.org> Cc: David Ahern <dsahern@...il.com> Cc: Frederic Weisbecker <fweisbec@...il.com> Cc: Jiri Olsa <jolsa@...hat.com> Cc: Namhyung Kim <namhyung@...il.com> Cc: Paul Mackerras <paulus@...ba.org> Cc: Peter Zijlstra <peterz@...radead.org> Cc: Stephane Eranian <eranian@...gle.com> Link: http://lkml.kernel.org/r/1407855871-15024-4-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com> --- tools/perf/util/record.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c index 58267a8..e778afd 100644 --- a/tools/perf/util/record.c +++ b/tools/perf/util/record.c @@ -14,6 +14,7 @@ static int perf_do_probe_api(setup_probe_fn_t fn, int cpu, const char *str) struct perf_evsel *evsel; unsigned long flags = perf_event_open_cloexec_flag(); int err = -EAGAIN, fd; + static pid_t pid = -1; evlist = perf_evlist__new(); if (!evlist) @@ -24,14 +25,22 @@ static int perf_do_probe_api(setup_probe_fn_t fn, int cpu, const char *str) evsel = perf_evlist__first(evlist); - fd = sys_perf_event_open(&evsel->attr, -1, cpu, -1, flags); - if (fd < 0) - goto out_delete; + while (1) { + fd = sys_perf_event_open(&evsel->attr, pid, cpu, -1, flags); + if (fd < 0) { + if (pid == -1 && errno == EACCES) { + pid = 0; + continue; + } + goto out_delete; + } + break; + } close(fd); fn(evsel); - fd = sys_perf_event_open(&evsel->attr, -1, cpu, -1, flags); + fd = sys_perf_event_open(&evsel->attr, pid, cpu, -1, flags); if (fd < 0) { if (errno == EINVAL) err = -EINVAL; @@ -201,6 +210,7 @@ bool perf_evlist__can_select_event(struct perf_evlist *evlist, const char *str) struct perf_evsel *evsel; int err, fd, cpu; bool ret = false; + pid_t pid = -1; temp_evlist = perf_evlist__new(); if (!temp_evlist) @@ -221,12 +231,20 @@ bool perf_evlist__can_select_event(struct perf_evlist *evlist, const char *str) cpu = evlist->cpus->map[0]; } - fd = sys_perf_event_open(&evsel->attr, -1, cpu, -1, - perf_event_open_cloexec_flag()); - if (fd >= 0) { - close(fd); - ret = true; + while (1) { + fd = sys_perf_event_open(&evsel->attr, pid, cpu, -1, + perf_event_open_cloexec_flag()); + if (fd < 0) { + if (pid == -1 && errno == EACCES) { + pid = 0; + continue; + } + goto out_delete; + } + break; } + close(fd); + ret = true; out_delete: perf_evlist__delete(temp_evlist); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@...r.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists