diff options
author | Ingo Molnar <mingo@elte.hu> | 2010-11-18 14:07:12 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-11-18 14:07:12 -0500 |
commit | ae51ce9061b1ddc0fde363913c932bee5b9bc5fd (patch) | |
tree | 40fd3d633714d2a53fdbd2bdd172fb61232d999a /kernel | |
parent | 072b198a4ad48bd722ec6d203d65422a4698eae7 (diff) | |
parent | 423478cde453eebdfcfebf4b8d378d8f5d49b853 (diff) |
Merge branch 'perf/core' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing into perf/core
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/perf_event.c | 9 | ||||
-rw-r--r-- | kernel/trace/trace_event_perf.c | 31 |
2 files changed, 30 insertions, 10 deletions
diff --git a/kernel/perf_event.c b/kernel/perf_event.c index cb6c0d2af68f..40c3aab648a1 100644 --- a/kernel/perf_event.c +++ b/kernel/perf_event.c | |||
@@ -4773,15 +4773,6 @@ static int perf_tp_event_init(struct perf_event *event) | |||
4773 | if (event->attr.type != PERF_TYPE_TRACEPOINT) | 4773 | if (event->attr.type != PERF_TYPE_TRACEPOINT) |
4774 | return -ENOENT; | 4774 | return -ENOENT; |
4775 | 4775 | ||
4776 | /* | ||
4777 | * Raw tracepoint data is a severe data leak, only allow root to | ||
4778 | * have these. | ||
4779 | */ | ||
4780 | if ((event->attr.sample_type & PERF_SAMPLE_RAW) && | ||
4781 | perf_paranoid_tracepoint_raw() && | ||
4782 | !capable(CAP_SYS_ADMIN)) | ||
4783 | return -EPERM; | ||
4784 | |||
4785 | err = perf_trace_init(event); | 4776 | err = perf_trace_init(event); |
4786 | if (err) | 4777 | if (err) |
4787 | return err; | 4778 | return err; |
diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c index 39c059ca670e..19a359d5e6d5 100644 --- a/kernel/trace/trace_event_perf.c +++ b/kernel/trace/trace_event_perf.c | |||
@@ -21,17 +21,46 @@ typedef typeof(unsigned long [PERF_MAX_TRACE_SIZE / sizeof(unsigned long)]) | |||
21 | /* Count the events in use (per event id, not per instance) */ | 21 | /* Count the events in use (per event id, not per instance) */ |
22 | static int total_ref_count; | 22 | static int total_ref_count; |
23 | 23 | ||
24 | static int perf_trace_event_perm(struct ftrace_event_call *tp_event, | ||
25 | struct perf_event *p_event) | ||
26 | { | ||
27 | /* No tracing, just counting, so no obvious leak */ | ||
28 | if (!(p_event->attr.sample_type & PERF_SAMPLE_RAW)) | ||
29 | return 0; | ||
30 | |||
31 | /* Some events are ok to be traced by non-root users... */ | ||
32 | if (p_event->attach_state == PERF_ATTACH_TASK) { | ||
33 | if (tp_event->flags & TRACE_EVENT_FL_CAP_ANY) | ||
34 | return 0; | ||
35 | } | ||
36 | |||
37 | /* | ||
38 | * ...otherwise raw tracepoint data can be a severe data leak, | ||
39 | * only allow root to have these. | ||
40 | */ | ||
41 | if (perf_paranoid_tracepoint_raw() && !capable(CAP_SYS_ADMIN)) | ||
42 | return -EPERM; | ||
43 | |||
44 | return 0; | ||
45 | } | ||
46 | |||
24 | static int perf_trace_event_init(struct ftrace_event_call *tp_event, | 47 | static int perf_trace_event_init(struct ftrace_event_call *tp_event, |
25 | struct perf_event *p_event) | 48 | struct perf_event *p_event) |
26 | { | 49 | { |
27 | struct hlist_head __percpu *list; | 50 | struct hlist_head __percpu *list; |
28 | int ret = -ENOMEM; | 51 | int ret; |
29 | int cpu; | 52 | int cpu; |
30 | 53 | ||
54 | ret = perf_trace_event_perm(tp_event, p_event); | ||
55 | if (ret) | ||
56 | return ret; | ||
57 | |||
31 | p_event->tp_event = tp_event; | 58 | p_event->tp_event = tp_event; |
32 | if (tp_event->perf_refcount++ > 0) | 59 | if (tp_event->perf_refcount++ > 0) |
33 | return 0; | 60 | return 0; |
34 | 61 | ||
62 | ret = -ENOMEM; | ||
63 | |||
35 | list = alloc_percpu(struct hlist_head); | 64 | list = alloc_percpu(struct hlist_head); |
36 | if (!list) | 65 | if (!list) |
37 | goto fail; | 66 | goto fail; |