[patch] somebody please fix this outstanding mmap(2) bug
Alexander Best
alexbestms at wwu.de
Mon Mar 22 15:22:47 UTC 2010
oops. forgot the patch. ;)
--
Alexander Best
-------------- next part --------------
Index: sys/vm/vm_mmap.c
===================================================================
--- sys/vm/vm_mmap.c (revision 205390)
+++ sys/vm/vm_mmap.c (working copy)
@@ -241,19 +241,23 @@
((prot & (PROT_READ | PROT_WRITE)) != (PROT_READ | PROT_WRITE)))
return (EINVAL);
flags |= MAP_ANON;
- pos = 0;
}
- /*
- * Align the file position to a page boundary,
- * and save its page offset component.
- */
- pageoff = (pos & PAGE_MASK);
- pos -= pageoff;
+ /* If MAP_ANON has been set the offset argument is being discarded. */
+ if (flags & MAP_ANON) {
+ pageoff = pos = 0;
+ } else {
+ /*
+ * Align the file position to a page boundary,
+ * and save its page offset component.
+ */
+ pageoff = (pos & PAGE_MASK);
+ pos -= pageoff;
- /* Adjust size for rounding (on both ends). */
- size += pageoff; /* low end... */
- size = (vm_size_t) round_page(size); /* hi end */
+ /* Adjust size for rounding (on both ends). */
+ size += pageoff; /* low end... */
+ size = (vm_size_t) round_page(size); /* hi end */
+ }
/*
* Check for illegal addresses. Watch out for address wrap... Note
@@ -300,7 +304,6 @@
handle = NULL;
handle_type = OBJT_DEFAULT;
maxprot = VM_PROT_ALL;
- pos = 0;
} else {
/*
* Mapping file, get fp for validation and
More information about the freebsd-hackers
mailing list