netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pktgen: Remove a dangerous debug print.
@ 2010-10-27 19:13 Nelson Elhage
  2010-10-27 19:21 ` David Miller
                   ` (3 more replies)
  0 siblings, 4 replies; 20+ messages in thread
From: Nelson Elhage @ 2010-10-27 19:13 UTC (permalink / raw)
  To: Robert Olsson; +Cc: linux-kernel, netdev, Eugene Teo, Nelson Elhage

We were allocating an arbitrarily-large buffer on the stack, which would allow a
buggy or malicious userspace program to overflow the kernel stack.

Since the debug printk() was just printing exactly the text passed from
userspace, it's probably just as easy for anyone who might use it to augment (or
just strace(1)) the program writing to the pktgen file, so let's just not bother
trying to print the whole buffer.

Signed-off-by: Nelson Elhage <nelhage@ksplice.com>
---
 net/core/pktgen.c |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 10a1ea7..de8e0da 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -888,14 +888,9 @@ static ssize_t pktgen_if_write(struct file *file,
 
 	i += len;
 
-	if (debug) {
-		char tb[count + 1];
-		if (copy_from_user(tb, user_buffer, count))
-			return -EFAULT;
-		tb[count] = 0;
-		printk(KERN_DEBUG "pktgen: %s,%lu  buffer -:%s:-\n", name,
-		       (unsigned long)count, tb);
-	}
+	if (debug)
+		printk(KERN_DEBUG "pktgen: %s,%lu\n", name,
+		       (unsigned long)count);
 
 	if (!strcmp(name, "min_pkt_size")) {
 		len = num_arg(&user_buffer[i], 10, &value);
-- 
1.7.1.31.g6297e


^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2010-11-01  3:47 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-27 19:13 [PATCH] pktgen: Remove a dangerous debug print Nelson Elhage
2010-10-27 19:21 ` David Miller
2010-10-27 19:28   ` Nelson Elhage
2010-10-27 19:30     ` David Miller
2010-10-27 19:41     ` Eric Dumazet
2010-10-27 19:49       ` Nelson Elhage
2010-10-27 20:38 ` Ben Greear
2010-10-27 22:12 ` [patch] fix stack overflow in pktgen_if_write() Dan Carpenter
2010-10-27 22:40   ` Dan Carpenter
2010-10-27 22:43   ` [patch v2] " Dan Carpenter
2010-10-27 23:06     ` Nelson Elhage
2010-10-28  6:05       ` Dan Carpenter
2010-10-28  6:05       ` [patch v3] " Dan Carpenter
2010-10-28 15:22         ` Nelson Elhage
2010-10-28 16:28           ` Dan Carpenter
2010-10-28 16:30             ` Nelson Elhage
2010-10-28 23:11         ` Andi Kleen
2010-11-01  3:47           ` Dan Carpenter
2010-10-28 15:20 ` [PATCH] pktgen: Limit how much data we copy onto the stack Nelson Elhage
2010-10-28 18:32   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).