lkml.org 
[lkml]   [2009]   [Mar]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 3/6] 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>
---
kernel/perf_counter.c | 4 ++++
1 file changed, 4 insertions(+)

Index: linux-2.6/kernel/perf_counter.c
===================================================================
--- linux-2.6.orig/kernel/perf_counter.c
+++ linux-2.6/kernel/perf_counter.c
@@ -1422,6 +1422,7 @@ struct perf_output_handle {
struct perf_counter *counter;
struct perf_mmap_data *data;
unsigned int offset;
+ unsigned int head;
int wakeup;
};

@@ -1447,6 +1448,7 @@ static int perf_output_begin(struct perf
handle->counter = counter;
handle->data = data;
handle->offset = offset;
+ handle->head = head;
handle->wakeup = (offset >> PAGE_SHIFT) != (head >> PAGE_SHIFT);

return 0;
@@ -1478,6 +1480,8 @@ static void perf_output_copy(struct perf
} while (len);

handle->offset = offset;
+
+ WARN_ON(handle->offset > handle->head);
}

#define perf_output_put(handle, x) \
--



\
 
 \ /
  Last update: 2009-03-25 12:41    [W:0.375 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site