[PATCH] Fix bound checking in do_mmap_pgoff()

From: Benjamin Herrenschmidt
Date: Sun Sep 19 2004 - 03:11:54 EST


Hi !

A small issue has been forever in do_mmap_pgoff() in the boundary checking
in the sense that it won't let you mmap with offset+len enclosing the last
page of the "address space". For example, an mmap of /dev/mem won't let you
map the last page of the physical address space (which I need for a ROM dump
tool on pmac). This fixes it:

Signed-off-by: Benjamin Herrenschmidt <benh@xxxxxxxxxxxxxxxxxxx>

===== mm/mmap.c 1.144 vs edited =====
--- 1.144/mm/mmap.c 2004-09-03 19:08:17 +10:00
+++ edited/mm/mmap.c 2004-09-19 18:04:34 +10:00
@@ -801,7 +801,7 @@
return -EINVAL;

/* offset overflow? */
- if ((pgoff + (len >> PAGE_SHIFT)) < pgoff)
+ if ((pgoff + (len >> PAGE_SHIFT) - 1) < pgoff)
return -EINVAL;

/* Too many mappings? */


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/