]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mm/nommu.c: add additional check for vread() just like vwrite() has done
authorChen Gang <gang.chen@asianux.com>
Fri, 7 Jun 2013 00:07:53 +0000 (10:07 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 7 Jun 2013 05:42:14 +0000 (15:42 +1000)
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 <gang.chen@asianux.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Michel Lespinasse <walken@google.com>
Cc: Rik van Riel <riel@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/nommu.c

index 886e07ce4d1decbba6a3eafd3a104a1d1d3a9257..0614ee1eeb664e26549a858a7d1e2739f93f526e 100644 (file)
@@ -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;
 }