summaryrefslogtreecommitdiffstats
path: root/sys/vm/vm_mmap.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2012-08-14 11:47:07 +0000
committerkib <kib@FreeBSD.org>2012-08-14 11:47:07 +0000
commit0d46b4715373f74bfedce6d75f31d50b7ab81c48 (patch)
tree412ba67166ca9d912698b771c4594a3ff5652286 /sys/vm/vm_mmap.c
parenta3d0fb01750888083d0ed5945f2d835c310c40e6 (diff)
downloadFreeBSD-src-0d46b4715373f74bfedce6d75f31d50b7ab81c48.zip
FreeBSD-src-0d46b4715373f74bfedce6d75f31d50b7ab81c48.tar.gz
Adjust the r205536, by allowing a non-zero offset for anonymous
mappings for a.out binaries. Apparently, a.out ld.so from FreeBSD 1.1.5.1 can issue such requests. Reported and tested by: Dan Plassche <dplassche@gmail.com> MFC after: 1 week
Diffstat (limited to 'sys/vm/vm_mmap.c')
-rw-r--r--sys/vm/vm_mmap.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c
index 3fccd9e..90a2aaf 100644
--- a/sys/vm/vm_mmap.c
+++ b/sys/vm/vm_mmap.c
@@ -207,11 +207,23 @@ sys_mmap(td, uap)
fp = NULL;
- /* Make sure mapping fits into numeric range, etc. */
- if ((uap->len == 0 && !SV_CURPROC_FLAG(SV_AOUT) &&
- curproc->p_osrel >= P_OSREL_MAP_ANON) ||
- ((flags & MAP_ANON) && (uap->fd != -1 || pos != 0)))
- return (EINVAL);
+ /*
+ * Enforce the constraints.
+ * Mapping of length 0 is only allowed for old binaries.
+ * Anonymous mapping shall specify -1 as filedescriptor and
+ * zero position for new code. Be nice to ancient a.out
+ * binaries and correct pos for anonymous mapping, since old
+ * ld.so sometimes issues anonymous map requests with non-zero
+ * pos.
+ */
+ if (!SV_CURPROC_FLAG(SV_AOUT)) {
+ if ((uap->len == 0 && curproc->p_osrel >= P_OSREL_MAP_ANON) ||
+ ((flags & MAP_ANON) != 0 && (uap->fd != -1 || pos != 0)))
+ return (EINVAL);
+ } else {
+ if ((flags & MAP_ANON) != 0)
+ pos = 0;
+ }
if (flags & MAP_STACK) {
if ((uap->fd != -1) ||
OpenPOWER on IntegriCloud