* [PATCH] gpu: vga: fix ZERO_SIZE_PTR dereference
@ 2010-11-21 17:39 Vasiliy Kulikov
0 siblings, 0 replies; only message in thread
From: Vasiliy Kulikov @ 2010-11-21 17:39 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, if it is -1 then
kmalloc() returns ZERO_SIZE_PTR. This pointer is then dereferenced.
Also one may pass too big count to generate OOM condition.
To prevent this limit 'count' maximum value. PAGE_SIZE looks OK.
Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
---
Compile tested only.
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 > PAGE_SIZE)
+ count = PAGE_SIZE;
kbuf = kmalloc(count + 1, GFP_KERNEL);
if (!kbuf)
--
1.7.0.4
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-11-21 17:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-21 17:39 [PATCH] gpu: vga: fix ZERO_SIZE_PTR dereference Vasiliy Kulikov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®