From: Chen Gang Date: Fri, 7 Jun 2013 00:07:53 +0000 (+1000) Subject: mm/nommu.c: add additional check for vread() just like vwrite() has done X-Git-Tag: next-20130607~2^2~401 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=20de3cf0c143a6dbcc77b0ee97d5edfc99143139;p=karo-tx-linux.git mm/nommu.c: add additional check for vread() just like vwrite() has done vwrite() checks for overflow. vread() should do the same thing. Since vwrite() checks the source buffer address, vread() should check the destination buffer address. Signed-off-by: Chen Gang Cc: Al Viro Cc: Michel Lespinasse Cc: Rik van Riel Signed-off-by: Andrew Morton --- diff --git a/mm/nommu.c b/mm/nommu.c index 886e07ce4d1d..0614ee1eeb66 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -282,6 +282,10 @@ EXPORT_SYMBOL(vmalloc_to_pfn); long vread(char *buf, char *addr, unsigned long count) { + /* Don't allow overflow */ + if ((unsigned long) buf + count < count) + count = -(unsigned long) buf; + memcpy(buf, addr, count); return count; }