Skip to content

Commit

Permalink
mm/nommu.c: add additional check for vread() just like vwrite() has done
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Michel Lespinasse <[email protected]>
Cc: Rik van Riel <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Chen Gang authored and torvalds committed Jul 3, 2013
1 parent dacbde0 commit 9bde916
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mm/nommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 9bde916

Please sign in to comment.