Date: Wed, 22 Aug 2012 19:27:17 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r239573 - stable/9/sys/vm Message-ID: <201208221927.q7MJRHEr083865@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Wed Aug 22 19:27:17 2012 New Revision: 239573 URL: http://svn.freebsd.org/changeset/base/239573 Log: MFC r239247: 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. Modified: stable/9/sys/vm/vm_mmap.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/vm/vm_mmap.c ============================================================================== --- stable/9/sys/vm/vm_mmap.c Wed Aug 22 19:25:57 2012 (r239572) +++ stable/9/sys/vm/vm_mmap.c Wed Aug 22 19:27:17 2012 (r239573) @@ -208,11 +208,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) ||
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201208221927.q7MJRHEr083865>