This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PING] [PATCH] Test for __mprotect failure in _dl_map_segments [BZ #20831]
- From: "Dmitry V. Levin" <ldv at altlinux dot org>
- To: libc-alpha at sourceware dot org
- Date: Tue, 27 Dec 2016 16:01:44 +0300
- Subject: [PING] [PATCH] Test for __mprotect failure in _dl_map_segments [BZ #20831]
- Authentication-results: sourceware.org; auth=none
- References: <20161116234522.GA8065@altlinux.org>
* elf/dl-map-segments.h (_dl_map_segments): Test for failure
of __mprotect to change protection on the excess portion
to disallow all access.
---
ChangeLog | 7 +++++++
elf/dl-map-segments.h | 21 +++++++++++++--------
2 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/elf/dl-map-segments.h b/elf/dl-map-segments.h
index e583f64..3dc030b 100644
--- a/elf/dl-map-segments.h
+++ b/elf/dl-map-segments.h
@@ -64,14 +64,19 @@ _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. */
+ int rc;
+ rc = __mprotect ((caddr_t) (l->l_addr + c->mapend),
+ loadcmds[nloadcmds - 1].mapstart - c->mapend,
+ PROT_NONE);
+ if (__glibc_unlikely (rc < 0))
+ return DL_MAP_SEGMENTS_ERROR_MPROTECT;
+ }
l->l_contiguous = 1;
--
ldv