All of lore.kernel.org
 help / color / mirror / Atom feed
From: jim.cromie@gmail.com
To: jbaron@redhat.com
Cc: greg@kroah.com, linux-kernel@vger.kernel.org,
	Jim Cromie <jim.cromie@gmail.com>
Subject: [PATCH 14/25] dynamic_debug: enlarge command/query write buffer
Date: Mon, 12 Dec 2011 16:12:40 -0700	[thread overview]
Message-ID: <1323731569-20644-14-git-send-email-jim.cromie@gmail.com> (raw)
In-Reply-To: <1323731569-20644-1-git-send-email-jim.cromie@gmail.com>

From: Jim Cromie <jim.cromie@gmail.com>

Current query write buffer is 256 bytes, on stack.  In comparison, the
ddebug_query boot-arg is 1024.  Allocate the buffer off heap, and
enlarge it to 4096 bytes, big enough for ~100 queries (at 40 bytes
each), and error out if not.  This makes it play nicely with large
query sets (to be added later).  The buffer should be enough for most
uses, and others should probably be split into subsets.

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
 lib/dynamic_debug.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index d285bb5..6e5b9a3 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -570,24 +570,32 @@ __setup("ddebug_query=", ddebug_setup_query);
  * File_ops->write method for <debugfs>/dynamic_debug/conrol.  Gathers the
  * command text from userspace, parses and executes it.
  */
+#define USER_BUF_PAGE 4095
 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)
+	if (len > USER_BUF_PAGE - 1) {
+		pr_warn("expected <%d bytes into control\n", USER_BUF_PAGE);
 		return -E2BIG;
-	if (copy_from_user(tmpbuf, ubuf, len))
+	}
+	tmpbuf = kmalloc(len + 1, GFP_KERNEL);
+	if (!tmpbuf)
+		return -ENOMEM;
+	if (copy_from_user(tmpbuf, ubuf, len)) {
+		kfree(tmpbuf);
 		return -EFAULT;
+	}
 	tmpbuf[len] = '\0';
 	if (verbose)
 		pr_info("read %d bytes from userspace\n", (int)len);
 
 	ret = ddebug_exec_query(tmpbuf);
+	kfree(tmpbuf);
 	if (ret)
 		return ret;
 
-- 
1.7.7.3


  parent reply	other threads:[~2011-12-12 23:17 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-12 23:12 [PATCH 01/25] kernel/module.c: fix compile err, warnings under ifdef DEBUGP, switch to pr_debug jim.cromie
2011-12-12 23:12 ` [PATCH 02/25] dynamic_debug: fix whitespace complaints from scripts/cleanfile jim.cromie
2011-12-12 23:12 ` [PATCH 03/25] dynamic_debug: drop enabled field from struct _ddebug, use _DPRINTK_FLAGS_PRINT jim.cromie
2011-12-12 23:12 ` [PATCH 04/25] dynamic_debug: make dynamic-debug supersede DEBUG ccflag jim.cromie
2011-12-12 23:12 ` [PATCH 05/25] dynamic_debug: change verbosity at runtime jim.cromie
2011-12-12 23:12 ` [PATCH 06/25] dynamic_debug: replace strcpy with strlcpy, in ddebug_setup_query() jim.cromie
2011-12-12 23:12 ` [PATCH 07/25] dynamic_debug: pr_err() call should not depend upon verbosity jim.cromie
2011-12-12 23:12 ` [PATCH 08/25] dynamic_debug: drop explicit !=NULL checks jim.cromie
2011-12-12 23:12 ` [PATCH 09/25] dynamic_debug: describe_flags with '=[pmflt_]*' jim.cromie
2011-12-12 23:12 ` [PATCH 10/25] dynamic_debug: tighten up error checking on debug queries jim.cromie
2011-12-12 23:12 ` [PATCH 11/25] dynamic_debug: early return if _ddebug table is empty jim.cromie
2011-12-12 23:12 ` [PATCH 12/25] dynamic_debug: reduce lineno field to a saner 18 bits jim.cromie
2011-12-12 23:12 ` [PATCH 13/25] dynamic_debug: chop off comments in ddebug_tokenize jim.cromie
2011-12-12 23:12 ` jim.cromie [this message]
2011-12-12 23:12 ` [PATCH 15/25] dynamic_debug: add trim_prefix() to provide source-root relative paths jim.cromie
2011-12-12 23:12 ` [PATCH 16/25] dynamic_debug: factor vpr_info_dq out of ddebug_parse_query jim.cromie
2011-12-12 23:12 ` [PATCH 17/25] dynamic_debug: process multiple debug-queries on a line jim.cromie
2011-12-12 23:12 ` [PATCH 18/25] dynamic_debug: Introduce global fake module param $module.dyndbg jim.cromie
2011-12-16  0:00   ` Rusty Russell
2011-12-17  5:10     ` Jim Cromie
2011-12-12 23:12 ` [PATCH 19/25] pnp: if CONFIG_DYNAMIC_DEBUG, use pnp.dyndbg instead of pnp.debug jim.cromie
2011-12-12 23:12 ` [PATCH 20/25] dynamic_debug: add modname arg to exec_query callchain jim.cromie
2011-12-12 23:12 ` [PATCH 21/25] dynamic_debug: protect "dyndbg" fake module param name at compile-time jim.cromie
2011-12-12 23:12 ` [PATCH 22/25] dynamic_debug: update Documentation/*, Kconfig.debug jim.cromie
2011-12-12 23:12 ` [PATCH 23/25] dynamic_debug: remove unneeded includes jim.cromie
  -- strict thread matches above, loose matches on Subject: below --
2011-11-30 20:27 [patch 00/25] dynamic-debug enhancements Jim Cromie
2011-12-06 18:59 ` Jim Cromie
2011-12-06 19:11   ` [patch 00/24 ] dynamic debug enhancements: multi-queries during mod-init jim.cromie
2011-12-06 19:11     ` [PATCH 14/25] dynamic_debug: enlarge command/query write buffer jim.cromie
2011-11-30 19:56 [patch 00/25] dynamic-debug during module initialization jim.cromie
2011-11-30 19:56 ` [PATCH 14/25] dynamic_debug: enlarge command/query write buffer jim.cromie

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=1323731569-20644-14-git-send-email-jim.cromie@gmail.com \
    --to=jim.cromie@gmail.com \
    --cc=greg@kroah.com \
    --cc=jbaron@redhat.com \
    --cc=linux-kernel@vger.kernel.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 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.