summaryrefslogtreecommitdiff
path: root/mm
diff options
context:
space:
mode:
authorChen Gang <gang.chen@asianux.com>2013-06-07 10:07:53 +1000
committerStephen Rothwell <sfr@canb.auug.org.au>2013-06-17 18:16:01 +1000
commit42e596797bc68cbab8bb3182f01ffe946d4f68a5 (patch)
tree1d83eb4b434bb3205dfda0536f677aed6fc01c0b /mm
parent8094dd486559abc8233c5989978603947a1f0c3b (diff)
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 <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>
Diffstat (limited to 'mm')
-rw-r--r--mm/nommu.c4
1 files changed, 4 insertions, 0 deletions
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;
}