public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] gpu: vga: limit kmalloc'ed memory size
@ 2010-11-22 17:11 Vasiliy Kulikov
  2010-11-22 18:09 ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: Vasiliy Kulikov @ 2010-11-22 17:11 UTC (permalink / raw)
  To: kernel-janitors
  Cc: Dave Airlie, Andrew Morton, Tiago Vignatti, Mike Travis,
	H. Peter Anvin, linux-kernel

count is not checked before kmalloc() call.  Too big value would
generate stack dump.  To prevent this limit 'count' maximum value.
1024 looks OK - the data should be the string of tens of bytes.

Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
---
 Compile tested only.

 v1 had incorrect comment text, as Dan Rosenberg noticed.

 drivers/gpu/vga/vgaarb.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c
index c380c65..09e3090 100644
--- a/drivers/gpu/vga/vgaarb.c
+++ b/drivers/gpu/vga/vgaarb.c
@@ -836,6 +836,8 @@ static ssize_t vga_arb_write(struct file *file, const char __user * buf,
 	int ret_val;
 	int i;
 
+	if (count > 1024)
+		count = 1024;
 
 	kbuf = kmalloc(count + 1, GFP_KERNEL);
 	if (!kbuf)
-- 
1.7.0.4


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

end of thread, other threads:[~2010-11-24 18:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-22 17:11 [PATCH v2] gpu: vga: limit kmalloc'ed memory size Vasiliy Kulikov
2010-11-22 18:09 ` Andrew Morton
2010-11-23 19:08   ` Vasiliy Kulikov
2010-11-23 20:46     ` Andrew Morton
2010-11-24 18:33       ` Vasiliy Kulikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox