From 9104191924e721f6bc70e731fa4954a71958e73e Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Mon, 15 May 2017 18:47:25 +0000 Subject: [PATCH] Fix the AT_EXECFD functionality. If the mapped object is linked at specific address, we must obey it. If AT_EXECFD is not used, only in-kernel ELF image activator needed to keep the mapping address, since only binaries are linked at the fixed address, and binaries are mapped by kernel in this case. Reviewed by: emaste Sponsored by: The FreeBSD Foundation MFC after: 2 weeks X-Differential revision: https://reviews.freebsd.org/D10701 --- libexec/rtld-elf/map_object.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libexec/rtld-elf/map_object.c b/libexec/rtld-elf/map_object.c index 30af4cefddbe..6f77d987e771 100644 --- a/libexec/rtld-elf/map_object.c +++ b/libexec/rtld-elf/map_object.c @@ -193,6 +193,8 @@ map_object(int fd, const char *path, const struct stat *sb) base_flags = 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) + base_flags |= MAP_FIXED | MAP_EXCL; mapbase = mmap(base_addr, mapsize, PROT_NONE, base_flags, -1, 0); if (mapbase == (caddr_t) -1) {