Date: Mon, 22 Mar 2010 16:22:37 +0100 (CET) From: Alexander Best <alexbestms@wwu.de> To: <freebsd-hackers@FreeBSD.org> Subject: Re: [patch] somebody please fix this outstanding mmap(2) bug Message-ID: <permail-2010032215223780e26a0b00007a34-a_best01@message-id.uni-muenster.de>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
oops. forgot the patch. ;)
--
Alexander Best
[-- Attachment #2 --]
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?permail-2010032215223780e26a0b00007a34-a_best01>
