From owner-svn-src-head@freebsd.org Sat Jun 24 17:04:28 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5550BDA245A; Sat, 24 Jun 2017 17:04:28 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1C4997310B; Sat, 24 Jun 2017 17:04:28 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v5OH4RjM017546; Sat, 24 Jun 2017 17:04:27 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v5OH4RSu017545; Sat, 24 Jun 2017 17:04:27 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201706241704.v5OH4RSu017545@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 24 Jun 2017 17:04:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r320318 - head/libexec/rtld-elf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Jun 2017 17:04:28 -0000 Author: kib Date: Sat Jun 24 17:04:27 2017 New Revision: 320318 URL: https://svnweb.freebsd.org/changeset/base/320318 Log: Use address space guard to implement inter-segment gap. Rtld checks and use old MAP_ANON/PROT_NONE method of creating gap if running on old kernel. Reviewed by: alc, markj Tested by: pho, Qualys Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/libexec/rtld-elf/map_object.c Modified: head/libexec/rtld-elf/map_object.c ============================================================================== --- head/libexec/rtld-elf/map_object.c Sat Jun 24 17:01:11 2017 (r320317) +++ head/libexec/rtld-elf/map_object.c Sat Jun 24 17:04:27 2017 (r320318) @@ -41,6 +41,8 @@ static Elf_Ehdr *get_elf_header(int, const char *, const struct stat *); static int convert_flags(int); /* Elf flags -> mmap flags */ +int __getosreldate(void); + /* * Map a shared object into memory. The "fd" argument is a file descriptor, * which must be open on the object and positioned at its beginning. @@ -190,7 +192,8 @@ map_object(int fd, const char *path, const struct stat base_vlimit = round_page(segs[nsegs]->p_vaddr + segs[nsegs]->p_memsz); mapsize = base_vlimit - base_vaddr; base_addr = (caddr_t) base_vaddr; - base_flags = MAP_PRIVATE | MAP_ANON | MAP_NOCORE; + base_flags = __getosreldate() >= P_OSREL_MAP_GUARD ? MAP_GUARD : + MAP_PRIVATE | MAP_ANON | MAP_NOCORE; if (npagesizes > 1 && round_page(segs[0]->p_filesz) >= pagesizes[1]) base_flags |= MAP_ALIGNED_SUPER; if (base_vaddr != 0)