Messages in this thread Patch in this message | | | Date | Wed, 25 Mar 2009 12:30:24 +0100 | From | Peter Zijlstra <> | 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) \ --
| |