Date: Wed, 5 Jul 2017 06:32:53 +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-11@freebsd.org Subject: svn commit: r320667 - stable/11/libexec/rtld-elf Message-ID: <201707050632.v656WrBw043677@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Wed Jul 5 06:32:53 2017 New Revision: 320667 URL: https://svnweb.freebsd.org/changeset/base/320667 Log: MFC r320318: Use address space guard to implement inter-segment gap. Modified: stable/11/libexec/rtld-elf/map_object.c Directory Properties: stable/11/ (props changed) Modified: stable/11/libexec/rtld-elf/map_object.c ============================================================================== --- stable/11/libexec/rtld-elf/map_object.c Wed Jul 5 06:18:00 2017 (r320666) +++ stable/11/libexec/rtld-elf/map_object.c Wed Jul 5 06:32:53 2017 (r320667) @@ -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,9 @@ 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 || + (P_OSREL_MAJOR(__getosreldate()) == 11 && __getosreldate() >= + P_OSREL_MAP_GUARD_11) ? 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?201707050632.v656WrBw043677>