[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20210607110231.1713929-1-liangyan.peng@linux.alibaba.com>
Date: Mon, 7 Jun 2021 19:02:31 +0800
From: Liangyan <liangyan.peng@...ux.alibaba.com>
To: linux-kernel@...r.kernel.org, Steven Rostedt <rostedt@...dmis.org>,
Ingo Molnar <mingo@...hat.com>
Cc: Xunlei Pang <xlpang@...ux.alibaba.com>, yinbinbin@...babacloud.com,
wetp <wetp.zy@...ux.alibaba.com>,
Liangyan <liangyan.peng@...ux.alibaba.com>
Subject: [PATCH] tracing: Correct the length check in use of filter buffer
Commit b220c049d519 ("tracing: Check length before giving out
the filter buffer") adds length check to protect trace data overflow
introduced in 0fc1b09ff1ff, seems that this fix can't prevent
overflow entirely, the length check should also take the sizeof
entry->array[0] into account, since this array[0] is filled the
length of trace data and occupy addtional space and risk overflow.
Fixes: 0fc1b09ff1ff ("tracing: Use temp buffer when filtering events")
Signed-off-by: Liangyan <liangyan.peng@...ux.alibaba.com>
---
kernel/trace/trace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index a21ef9cd2aae..9299057feb56 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2736,7 +2736,7 @@ trace_event_buffer_lock_reserve(struct trace_buffer **current_rb,
(entry = this_cpu_read(trace_buffered_event))) {
/* Try to use the per cpu buffer first */
val = this_cpu_inc_return(trace_buffered_event_cnt);
- if ((len < (PAGE_SIZE - sizeof(*entry))) && val == 1) {
+ if ((len < (PAGE_SIZE - sizeof(*entry) - sizeof(entry->array[0]))) && val == 1) {
trace_event_setup(entry, type, trace_ctx);
entry->array[0] = len;
return entry;
--
2.14.4.44.g2045bb6
Powered by blists - more mailing lists