[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-91d876bd14c82826b69bf23f502cb283959ebb1f@git.kernel.org>
Date: Wed, 25 Mar 2009 12:06:45 GMT
From: Peter Zijlstra <a.p.zijlstra@...llo.nl>
To: linux-tip-commits@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, paulus@...ba.org, hpa@...or.com,
mingo@...hat.com, a.p.zijlstra@...llo.nl, efault@....de,
arjan@...radead.org, tglx@...utronix.de, fengguang.wu@...el.com,
mingo@...e.hu
Subject: [tip:perfcounters/core] perf_counter: sanity check on the output API
Commit-ID: 91d876bd14c82826b69bf23f502cb283959ebb1f
Gitweb: http://git.kernel.org/tip/91d876bd14c82826b69bf23f502cb283959ebb1f
Author: Peter Zijlstra <a.p.zijlstra@...llo.nl>
AuthorDate: Wed, 25 Mar 2009 12:30:24 +0100
Committer: Ingo Molnar <mingo@...e.hu>
CommitDate: Wed, 25 Mar 2009 13:02:52 +0100
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@...llo.nl>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Mike Galbraith <efault@....de>
Cc: Arjan van de Ven <arjan@...radead.org>
Cc: Wu Fengguang <fengguang.wu@...el.com>
LKML-Reference: <20090325113316.921433024@...llo.nl>
Signed-off-by: Ingo Molnar <mingo@...e.hu>
---
kernel/perf_counter.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c
index d76e311..7669afe 100644
--- a/kernel/perf_counter.c
+++ b/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_output_handle *handle,
handle->counter = counter;
handle->data = data;
handle->offset = offset;
+ handle->head = head;
handle->wakeup = (offset >> PAGE_SHIFT) != (head >> PAGE_SHIFT);
return 0;
@@ -1485,6 +1487,8 @@ static void perf_output_copy(struct perf_output_handle *handle,
} while (len);
handle->offset = offset;
+
+ WARN_ON_ONCE(handle->offset > handle->head);
}
#define perf_output_put(handle, x) \
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists