Skip to contentSkip to conversation

mm/nommu.c: add additional check for vread() just like vwrite() has done.

PATCH New Chen Gang 1 participant 1 message May 17, 2013

Subsystems (2)
lore
Share & tools
lore

Chen Gang

author
#0 lore raw

PATCH 1/1 mm/nommu.c: add additional check for vread() just like vwrite() has done.

Since vwrite() has already check whether overflow, as a pair function, vread() also need do the same thing.

Since vwrite() check the source buffer address, vread() should check the destination buffer address.

---
 mm/nommu.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
mm/nommu.c +4 -0
index 886e07c..0614ee1 100644
@@ -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;
 }
Signature · 7 lines
1.7.7.6

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>