Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 Jun 2017 17:04:27 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r320318 - head/libexec/rtld-elf
Message-ID:  <201706241704.v5OH4RSu017545@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201706241704.v5OH4RSu017545>