aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/perf_counter.c
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2009-03-25 07:30:24 -0400
committerIngo Molnar <mingo@elte.hu>2009-04-06 03:30:33 -0400
commit63e35b25d6b5c3136d22ef249dbbf96716aa08bf (patch)
tree213eaa8ffcbdd3efd0c8489a84658b9fc1b870c7 /kernel/perf_counter.c
parent5c1481943250ab65fa5130e05ec479c93216e9f7 (diff)
perf_counter: sanity check on the output API
Ensure we never write more than we said we would. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> Cc: Mike Galbraith <efault@gmx.de> Cc: Arjan van de Ven <arjan@infradead.org> Cc: Wu Fengguang <fengguang.wu@intel.com> Orig-LKML-Reference: <20090325113316.921433024@chello.nl> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/perf_counter.c')
-rw-r--r--kernel/perf_counter.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c
index d76e3112d386..7669afe82cc7 100644
--- a/kernel/perf_counter.c
+++ b/kernel/perf_counter.c
@@ -1422,6 +1422,7 @@ struct perf_output_handle {
1422 struct perf_counter *counter; 1422 struct perf_counter *counter;
1423 struct perf_mmap_data *data; 1423 struct perf_mmap_data *data;
1424 unsigned int offset; 1424 unsigned int offset;
1425 unsigned int head;
1425 int wakeup; 1426 int wakeup;
1426}; 1427};
1427 1428
@@ -1447,6 +1448,7 @@ static int perf_output_begin(struct perf_output_handle *handle,
1447 handle->counter = counter; 1448 handle->counter = counter;
1448 handle->data = data; 1449 handle->data = data;
1449 handle->offset = offset; 1450 handle->offset = offset;
1451 handle->head = head;
1450 handle->wakeup = (offset >> PAGE_SHIFT) != (head >> PAGE_SHIFT); 1452 handle->wakeup = (offset >> PAGE_SHIFT) != (head >> PAGE_SHIFT);
1451 1453
1452 return 0; 1454 return 0;
@@ -1485,6 +1487,8 @@ static void perf_output_copy(struct perf_output_handle *handle,
1485 } while (len); 1487 } while (len);
1486 1488
1487 handle->offset = offset; 1489 handle->offset = offset;
1490
1491 WARN_ON_ONCE(handle->offset > handle->head);
1488} 1492}
1489 1493
1490#define perf_output_put(handle, x) \ 1494#define perf_output_put(handle, x) \