From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
stable@vger.kernel.org, Jing Xia <jing.xia@spreadtrum.com>,
Chunyan Zhang <chunyan.zhang@spreadtrum.com>
Subject: [PATCH 5/5] tracing: Fix possible double free on failure of allocating trace buffer
Date: Wed, 27 Dec 2017 14:33:12 -0500 [thread overview]
Message-ID: <20171227193359.922187142@goodmis.org> (raw)
In-Reply-To: 20171227193307.929591859@goodmis.org
[-- Attachment #1: 0005-tracing-Fix-possible-double-free-on-failure-of-alloc.patch --]
[-- Type: text/plain, Size: 1200 bytes --]
From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
Jing Xia and Chunyan Zhang reported that on failing to allocate part of the
tracing buffer, memory is freed, but the pointers that point to them are not
initialized back to NULL, and later paths may try to free the freed memory
again. Jing and Chunyan fixed one of the locations that does this, but
missed a spot.
Link: http://lkml.kernel.org/r/20171226071253.8968-1-chunyan.zhang@spreadtrum.com
Cc: stable@vger.kernel.org
Fixes: 737223fbca3b1 ("tracing: Consolidate buffer allocation code")
Reported-by: Jing Xia <jing.xia@spreadtrum.com>
Reported-by: Chunyan Zhang <chunyan.zhang@spreadtrum.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
kernel/trace/trace.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 0e53d46544b8..2a8d8a294345 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -7580,6 +7580,7 @@ allocate_trace_buffer(struct trace_array *tr, struct trace_buffer *buf, int size
buf->data = alloc_percpu(struct trace_array_cpu);
if (!buf->data) {
ring_buffer_free(buf->buffer);
+ buf->buffer = NULL;
return -ENOMEM;
}
--
2.13.2
prev parent reply other threads:[~2017-12-27 19:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20171227193307.929591859@goodmis.org>
2017-12-27 19:33 ` [PATCH 1/5] ring-buffer: Mask out the info bits when returning buffer page length Steven Rostedt
2017-12-27 19:33 ` [PATCH 2/5] tracing: Remove extra zeroing out of the ring buffer page Steven Rostedt
2017-12-27 19:33 ` [PATCH 3/5] ring-buffer: Do no reuse reader page if still in use Steven Rostedt
2017-12-27 19:33 ` [PATCH 4/5] tracing: Fix crash when it fails to alloc ring buffer Steven Rostedt
2017-12-27 19:33 ` Steven Rostedt [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171227193359.922187142@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=chunyan.zhang@spreadtrum.com \
--cc=jing.xia@spreadtrum.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).