gpu: vga: fix ZERO_SIZE_PTR dereference
Subsystems (3)
PATCH 1/1 gpu: vga: fix ZERO_SIZE_PTR dereference
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 <[email protected]>
---
Compile tested only.
drivers/gpu/vga/vgaarb.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/gpu/vga/vgaarb.c +2 -0
@@ -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)
Signature · 1 line
1.7.0.4