All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Li Zefan <lizf@cn.fujitsu.com>
Subject: [PATCH 3/7] tracing: fix a typo in tracing_cpumask_write()
Date: Mon, 15 Jun 2009 11:42:29 -0400	[thread overview]
Message-ID: <20090615154410.950808103@goodmis.org> (raw)
In-Reply-To: 20090615154226.058101204@goodmis.org

[-- Attachment #1: 0003-tracing-fix-a-typo-in-tracing_cpumask_write.patch --]
[-- Type: text/plain, Size: 1572 bytes --]

From: Li Zefan <lizf@cn.fujitsu.com>

It's tracing_cpumask_new that should be kfree()ed.

This causes tracing_cpumask to be freed due to the typo:

 # echo z > tracing_cpumask
 bash: echo: write error: Invalid argument

And subsequent reads/writes to tracing_cpuamsk will access this
already-freed tracing_cpumask, thus may lead to crash.

[ Impact: fix leak and crash when writing invalid val to tracing_cpumask ]

Acked-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
LKML-Reference: <4A35B86A.7070608@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 8acd9b8..7355a38 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2191,11 +2191,12 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
 	if (!alloc_cpumask_var(&tracing_cpumask_new, GFP_KERNEL))
 		return -ENOMEM;
 
-	mutex_lock(&tracing_cpumask_update_lock);
 	err = cpumask_parse_user(ubuf, count, tracing_cpumask_new);
 	if (err)
 		goto err_unlock;
 
+	mutex_lock(&tracing_cpumask_update_lock);
+
 	local_irq_disable();
 	__raw_spin_lock(&ftrace_max_lock);
 	for_each_tracing_cpu(cpu) {
@@ -2223,8 +2224,7 @@ tracing_cpumask_write(struct file *filp, const char __user *ubuf,
 	return count;
 
 err_unlock:
-	mutex_unlock(&tracing_cpumask_update_lock);
-	free_cpumask_var(tracing_cpumask);
+	free_cpumask_var(tracing_cpumask_new);
 
 	return err;
 }
-- 
1.6.3.1

-- 

  parent reply	other threads:[~2009-06-15 15:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-15 15:42 [PATCH 0/7] [GIT PULL] updates for 2.6.31 Steven Rostedt
2009-06-15 15:42 ` [PATCH 1/7] cpumask: use new operators in kernel/trace Steven Rostedt
2009-06-15 15:42 ` [PATCH 2/7] tracing: fix undeclared PAGE_SIZE in include/linux/trace_seq.h Steven Rostedt
2009-06-15 15:42 ` Steven Rostedt [this message]
2009-06-15 15:42 ` [PATCH 4/7] tracing: replace a GFP_ATOMIC with GFP_KERNEL allocation Steven Rostedt
2009-06-15 15:58   ` Ingo Molnar
2009-06-15 15:42 ` [PATCH 5/7] tracing/filters: operand can be negative Steven Rostedt
2009-06-15 15:42 ` [PATCH 6/7] tracing/filters: strloc should be unsigned short Steven Rostedt
2009-06-15 15:42 ` [PATCH 7/7] ring-buffer: prevent adding write in discarded area Steven Rostedt
2009-06-15 15:56 ` [PATCH 0/7] [GIT PULL] updates for 2.6.31 Ingo Molnar

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=20090615154410.950808103@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=mingo@elte.hu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.