All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/nommu.c: add additional check for vread() just like vwrite() has done.
@ 2013-05-17 12:25 ` Chen Gang
  0 siblings, 0 replies; 2+ messages in thread
From: Chen Gang @ 2013-05-17 12:25 UTC (permalink / raw)
  To: Al Viro, walken, riel, khlebnikov
  Cc: Andrew Morton, linux-mm, linux-kernel@vger.kernel.org


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.


Signed-off-by: Chen Gang <gang.chen@asianux.com>
---
 mm/nommu.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/mm/nommu.c b/mm/nommu.c
index 886e07c..0614ee1 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;
 }
-- 
1.7.7.6

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-05-17 12:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-17 12:25 [PATCH] mm/nommu.c: add additional check for vread() just like vwrite() has done Chen Gang
2013-05-17 12:25 ` Chen Gang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.