From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935442Ab1JGUjD (ORCPT ); Fri, 7 Oct 2011 16:39:03 -0400 Received: from mail-gx0-f174.google.com ([209.85.161.174]:58642 "EHLO mail-gx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758717Ab1JGUe3 (ORCPT ); Fri, 7 Oct 2011 16:34:29 -0400 From: jim.cromie@gmail.com To: jbaron@redhat.com Cc: greg@kroah.com, joe@perches.com, bart.vanassche@gmail.com, linux-kernel@vger.kernel.org, Jim Cromie Subject: [PATCH 10/26] dynamic_debug: enlarge command/query write buffer Date: Fri, 7 Oct 2011 14:33:16 -0600 Message-Id: <1318019612-20068-11-git-send-email-jim.cromie@gmail.com> X-Mailer: git-send-email 1.7.4.4 In-Reply-To: <1318019612-20068-1-git-send-email-jim.cromie@gmail.com> References: <1316642115-20029-1-git-send-email-jim.cromie@gmail.com> <1318019612-20068-1-git-send-email-jim.cromie@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jim Cromie Current write buffer is 256 bytes, on stack. Allocate it off heap, and enlarge it to 4096 bytes, big enough for ~100 queries (at 40 bytes each), and error out if not. This should be enough for most uses, and others can be split into 2 writes. This makes it play nicely with: $> cat debug-queries-file > /dbg/dynamic_debug/control Signed-off-by: Jim Cromie --- 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 4bf27f3..2b3393f 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -590,24 +590,32 @@ __setup("ddebug_query=", ddebug_setup_query); * File_ops->write method for /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_queries(tmpbuf); + kfree(tmpbuf); if (ret) return ret; -- 1.7.4.4