aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/perf_event.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 3f2cc313ee25..7a932526946f 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -4920,6 +4920,13 @@ static int perf_event_set_output(struct perf_event *event, int output_fd)
4920 int fput_needed = 0; 4920 int fput_needed = 0;
4921 int ret = -EINVAL; 4921 int ret = -EINVAL;
4922 4922
4923 /*
4924 * Don't allow output of inherited per-task events. This would
4925 * create performance issues due to cross cpu access.
4926 */
4927 if (event->cpu == -1 && event->attr.inherit)
4928 return -EINVAL;
4929
4923 if (!output_fd) 4930 if (!output_fd)
4924 goto set; 4931 goto set;
4925 4932
@@ -4940,6 +4947,18 @@ static int perf_event_set_output(struct perf_event *event, int output_fd)
4940 if (event->data) 4947 if (event->data)
4941 goto out; 4948 goto out;
4942 4949
4950 /*
4951 * Don't allow cross-cpu buffers
4952 */
4953 if (output_event->cpu != event->cpu)
4954 goto out;
4955
4956 /*
4957 * If its not a per-cpu buffer, it must be the same task.
4958 */
4959 if (output_event->cpu == -1 && output_event->ctx != event->ctx)
4960 goto out;
4961
4943 atomic_long_inc(&output_file->f_count); 4962 atomic_long_inc(&output_file->f_count);
4944 4963
4945set: 4964set: