From: Chen Gang Date: Wed, 3 Jul 2013 22:02:36 +0000 (-0700) Subject: mm/nommu.c: add additional check for vread() just like vwrite() has done X-Git-Tag: v3.11-rc1~99^2~355 X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=9bde916bc73255dcee3d8aded990443675daa707;p=~emulex%2Finfiniband.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 Signed-off-by: Linus Torvalds --- diff --git a/mm/nommu.c b/mm/nommu.c index 298884dcd6e..1898b2fe9da 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; }