]> 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>
Wed, 19 Jun 2013 00:06:12 +0000 (10:06 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 19 Jun 2013 07:13:08 +0000 (17:13 +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;
 }