[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1311630170-26057-8-git-send-email-jim.cromie@gmail.com>
Date: Mon, 25 Jul 2011 15:42:32 -0600
From: Jim Cromie <jim.cromie@...il.com>
To: jbaron@...hat.com
Cc: bvanassche@....org, joe@...ches.com, gregkh@...e.de,
linux-kernel@...r.kernel.org, gnb@...h.org,
Jim Cromie <jim.cromie@...il.com>
Subject: [PATCH 07/25] dynamic_debug: enlarge command/query write buffer
Current write buffer is 256 bytes, on stack. Allocate it off heap,
to fit the size passed by user. This makes it play nicely with:
$> cat debug-queries-file > /dbg/dynamic_debug/control
Signed-off-by: Jim Cromie <jim.cromie@...il.com>
---
lib/dynamic_debug.c | 13 ++++++++-----
1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 2539517..8ce941a 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -555,20 +555,23 @@ __setup("ddebug_query=", ddebug_setup_query);
static ssize_t ddebug_proc_write(struct file *file, const char __user *ubuf,
size_t len, loff_t *offp)
{
- char tmpbuf[256];
+ char *tmpbuf;
int ret;
if (len == 0)
return 0;
- /* we don't check *offp -- multiple writes() are allowed */
- if (len > sizeof(tmpbuf)-1)
- return -E2BIG;
- if (copy_from_user(tmpbuf, ubuf, len))
+ tmpbuf = kmalloc(len, GFP_KERNEL);
+ if (!tmpbuf)
+ return -ENOMEM;
+ if (copy_from_user(tmpbuf, ubuf, len)) {
+ kfree(tmpbuf);
return -EFAULT;
+ }
tmpbuf[len] = '\0';
pr_debug("read %d bytes from userspace\n", (int)len);
ret = ddebug_exec_queries(tmpbuf);
+ kfree(tmpbuf);
if (ret)
return ret;
--
1.7.4.1
--
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