All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li Zefan <lizf@cn.fujitsu.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: "K.Prasad" <prasad@linux.vnet.ibm.com>,
	Alan Stern <stern@rowland.harvard.edu>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 5/8] ksym_tracer: NIL-terminate user input filter
Date: Tue, 07 Jul 2009 13:54:08 +0800	[thread overview]
Message-ID: <4A52E300.7020601@cn.fujitsu.com> (raw)
In-Reply-To: <4A52E291.1020408@cn.fujitsu.com>

Make sure the user input string is NULL-terminated.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 kernel/trace/trace_ksym.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/kernel/trace/trace_ksym.c b/kernel/trace/trace_ksym.c
index 72fcb46..8cbed5a 100644
--- a/kernel/trace/trace_ksym.c
+++ b/kernel/trace/trace_ksym.c
@@ -264,11 +264,7 @@ static ssize_t ksym_trace_filter_write(struct file *file,
 	unsigned long ksym_addr = 0;
 	int ret, op, changed = 0;
 
-	/* Ignore echo "" > ksym_trace_filter */
-	if (count == 0)
-		return 0;
-
-	input_string = kzalloc(count, GFP_KERNEL);
+	input_string = kzalloc(count + 1, GFP_KERNEL);
 	if (!input_string)
 		return -ENOMEM;
 
@@ -276,6 +272,7 @@ static ssize_t ksym_trace_filter_write(struct file *file,
 		kfree(input_string);
 		return -EFAULT;
 	}
+	input_string[count] = '\0';
 
 	ret = op = parse_ksym_trace_str(input_string, &ksymname, &ksym_addr);
 	if (ret < 0) {
-- 
1.5.4.rc3


  parent reply	other threads:[~2009-07-07  5:54 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-07  5:52 [PATCH 0/8] ksym_tracer: various fixes Li Zefan
2009-07-07  5:52 ` [PATCH 1/8] ksym_tracer: Extract trace entry from struct trace_ksym Li Zefan
2009-07-07 21:25   ` Frederic Weisbecker
2009-07-08  0:55     ` Li Zefan
2009-11-21 13:33   ` [tip:perf/core] " tip-bot for Li Zefan
2009-07-07  5:52 ` [PATCH 2/8] ksym_tracer: Rewrite ksym_trace_filter_read() Li Zefan
2009-07-07 21:29   ` Frederic Weisbecker
2009-07-11  5:54   ` K.Prasad
2009-11-21 13:34   ` [tip:perf/core] " tip-bot for Li Zefan
2009-07-07  5:53 ` [PATCH 3/8] ksym_tracer: Fix validation of access type Li Zefan
2009-11-21 13:34   ` [tip:perf/core] " tip-bot for Li Zefan
2009-07-07  5:53 ` [PATCH 4/8] ksym_tracer: Fix validation of length " Li Zefan
2009-11-21 13:34   ` [tip:perf/core] " tip-bot for Li Zefan
2009-07-07  5:54 ` Li Zefan [this message]
2009-11-21 13:34   ` [tip:perf/core] ksym_tracer: NIL-terminate user input filter tip-bot for Li Zefan
2009-07-07  5:54 ` [PATCH 6/8] ksym_tracer: Report error when failed to re-register hbp Li Zefan
2009-11-21 13:34   ` [tip:perf/core] " tip-bot for Li Zefan
2009-07-07  5:54 ` [PATCH 7/8] ksym_tracer: Fix memory leak Li Zefan
2009-11-21 13:35   ` [tip:perf/core] " tip-bot for Li Zefan
2009-07-07  5:55 ` [PATCH 8/8] ksym_tracer: Fix the output of stat tracing Li Zefan
2009-11-21 13:35   ` [tip:perf/core] " tip-bot for Li Zefan
2009-07-07 23:18 ` [PATCH 0/8] ksym_tracer: various fixes Frederic Weisbecker
2009-07-10 10:01   ` Ingo Molnar
2009-07-11  5:54   ` K.Prasad

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=4A52E300.7020601@cn.fujitsu.com \
    --to=lizf@cn.fujitsu.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=prasad@linux.vnet.ibm.com \
    --cc=rostedt@goodmis.org \
    --cc=stern@rowland.harvard.edu \
    /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.