lkml.org 
[lkml]   [2013]   [Sep]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 11/11] perf: Avoid uninitialized sample type reference in __perf_event__output_id_sample
Date
From: Andi Kleen <ak@linux.intel.com>

__perf_event__output_id_sample looks at data->type to decide
what to output.

A lot of of the custom output functions, for example perf_log_throttle
start with perf_event_header__init_id, which only initializes
the header when event->attr.sample_id_all is true.

But when this is false the output function is still called,
and will look at an uninitialized header.

I changed all the callers to perf_event_header__init_id
to __perf_event_header__init_id which unconditionally
initializes the header.

FWIW I'm not fully sure this is the correct fix and what the
exact semantics of sample_id_all are supposed to be.
Should it disable all throttling etc. messages?
Please review carefully.

Cc: mingo@kernel.org
Cc: eranian@google.com
Cc: peterz@infradead.org
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
kernel/events/core.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index cb4238e..0b15209 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -4732,7 +4732,7 @@ perf_event_read_event(struct perf_event *event,
};
int ret;

- perf_event_header__init_id(&read_event.header, &sample, event);
+ __perf_event_header__init_id(&read_event.header, &sample, event);
ret = perf_output_begin(&handle, event, read_event.header.size);
if (ret)
return;
@@ -4837,7 +4837,7 @@ static void perf_event_task_output(struct perf_event *event,
if (!perf_event_task_match(event))
return;

- perf_event_header__init_id(&task_event->event_id.header, &sample, event);
+ __perf_event_header__init_id(&task_event->event_id.header, &sample, event);

ret = perf_output_begin(&handle, event,
task_event->event_id.header.size);
@@ -4931,7 +4931,7 @@ static void perf_event_comm_output(struct perf_event *event,
if (!perf_event_comm_match(event))
return;

- perf_event_header__init_id(&comm_event->event_id.header, &sample, event);
+ __perf_event_header__init_id(&comm_event->event_id.header, &sample, event);
ret = perf_output_begin(&handle, event,
comm_event->event_id.header.size);

@@ -5063,7 +5063,7 @@ static void perf_event_mmap_output(struct perf_event *event,
mmap_event->event_id.header.size += sizeof(mmap_event->ino_generation);
}

- perf_event_header__init_id(&mmap_event->event_id.header, &sample, event);
+ __perf_event_header__init_id(&mmap_event->event_id.header, &sample, event);
ret = perf_output_begin(&handle, event,
mmap_event->event_id.header.size);
if (ret)
@@ -5237,7 +5237,7 @@ static void perf_log_throttle(struct perf_event *event, int enable)
if (enable)
throttle_event.header.type = PERF_RECORD_UNTHROTTLE;

- perf_event_header__init_id(&throttle_event.header, &sample, event);
+ __perf_event_header__init_id(&throttle_event.header, &sample, event);

ret = perf_output_begin(&handle, event,
throttle_event.header.size);
--
1.8.3.1


\
 
 \ /
  Last update: 2013-09-30 23:01    [W:0.275 / U:0.664 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site