Check for __mprotect failure in _dl_map_segments [BZ #20831]

* elf/dl-map-segments.h (_dl_map_segments): Check for failure
of __mprotect to change protection on the excess portion
to disallow all access.
This commit is contained in:
Dmitry V. Levin 2016-11-16 22:49:25 +00:00
parent bf7730194f
commit 9ace4692b2
2 changed files with 19 additions and 8 deletions

View File

@ -1,3 +1,10 @@
2017-04-09 Dmitry V. Levin <ldv@altlinux.org>
[BZ #20831]
* elf/dl-map-segments.h (_dl_map_segments): Check for failure
of __mprotect to change protection on the excess portion
to disallow all access.
2017-04-07 H.J. Lu <hongjiu.lu@intel.com> 2017-04-07 H.J. Lu <hongjiu.lu@intel.com>
* sysdeps/i386/fpu/fclrexcpt.c (__feclearexcept): Use * sysdeps/i386/fpu/fclrexcpt.c (__feclearexcept): Use

View File

@ -64,14 +64,18 @@ _dl_map_segments (struct link_map *l, int fd,
l->l_addr = l->l_map_start - c->mapstart; l->l_addr = l->l_map_start - c->mapstart;
if (has_holes) if (has_holes)
/* Change protection on the excess portion to disallow all access; {
the portions we do not remap later will be inaccessible as if /* Change protection on the excess portion to disallow all access;
unallocated. Then jump into the normal segment-mapping loop to the portions we do not remap later will be inaccessible as if
handle the portion of the segment past the end of the file unallocated. Then jump into the normal segment-mapping loop to
mapping. */ handle the portion of the segment past the end of the file
__mprotect ((caddr_t) (l->l_addr + c->mapend), mapping. */
loadcmds[nloadcmds - 1].mapstart - c->mapend, if (__glibc_unlikely
PROT_NONE); (__mprotect ((caddr_t) (l->l_addr + c->mapend),
loadcmds[nloadcmds - 1].mapstart - c->mapend,
PROT_NONE) < 0))
return DL_MAP_SEGMENTS_ERROR_MPROTECT;
}
l->l_contiguous = 1; l->l_contiguous = 1;