[PATCH 07/25] dynamic_debug: enlarge command/query write buffer

From: Jim Cromie
Date: Mon Jul 25 2011 - 17:46:51 EST


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@xxxxxxxxx>
---
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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/