diff options
author | Dmitry V. Levin <ldv@altlinux.org> | 2016-11-16 22:49:25 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@altlinux.org> | 2017-04-09 23:34:33 +0000 |
commit | 9ace4692b2fa96c1c92177bb51e5e36680de25ad (patch) | |
tree | 5f0d056b2ab3aff4276e9b585abf615572f3ee4c | |
parent | bf7730194fed694a9ce821c306683266a5a7b78b (diff) | |
download | glibc-9ace4692b2fa96c1c92177bb51e5e36680de25ad.zip glibc-9ace4692b2fa96c1c92177bb51e5e36680de25ad.tar.gz glibc-9ace4692b2fa96c1c92177bb51e5e36680de25ad.tar.bz2 |
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.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | elf/dl-map-segments.h | 20 |
2 files changed, 19 insertions, 8 deletions
@@ -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> * sysdeps/i386/fpu/fclrexcpt.c (__feclearexcept): Use diff --git a/elf/dl-map-segments.h b/elf/dl-map-segments.h index 31d6861..d36f9bd 100644 --- a/elf/dl-map-segments.h +++ b/elf/dl-map-segments.h @@ -64,14 +64,18 @@ _dl_map_segments (struct link_map *l, int fd, l->l_addr = l->l_map_start - c->mapstart; 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 - unallocated. Then jump into the normal segment-mapping loop to - handle the portion of the segment past the end of the file - mapping. */ - __mprotect ((caddr_t) (l->l_addr + c->mapend), - loadcmds[nloadcmds - 1].mapstart - c->mapend, - PROT_NONE); + { + /* Change protection on the excess portion to disallow all access; + the portions we do not remap later will be inaccessible as if + unallocated. Then jump into the normal segment-mapping loop to + handle the portion of the segment past the end of the file + mapping. */ + if (__glibc_unlikely + (__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; |