From owner-svn-src-all@FreeBSD.ORG Tue Aug 14 11:47:07 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D81841065740; Tue, 14 Aug 2012 11:47:07 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BFF448FC20; Tue, 14 Aug 2012 11:47:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q7EBl7DQ090121; Tue, 14 Aug 2012 11:47:07 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q7EBl7C1090119; Tue, 14 Aug 2012 11:47:07 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201208141147.q7EBl7C1090119@svn.freebsd.org> From: Konstantin Belousov Date: Tue, 14 Aug 2012 11:47:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r239247 - head/sys/vm X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Aug 2012 11:47:08 -0000 Author: kib Date: Tue Aug 14 11:47:07 2012 New Revision: 239247 URL: http://svn.freebsd.org/changeset/base/239247 Log: 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 MFC after: 1 week Modified: head/sys/vm/vm_mmap.c Modified: head/sys/vm/vm_mmap.c ============================================================================== --- head/sys/vm/vm_mmap.c Tue Aug 14 11:45:47 2012 (r239246) +++ head/sys/vm/vm_mmap.c Tue Aug 14 11:47:07 2012 (r239247) @@ -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) ||