This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Test for mprotect failure in dl-load.c (bug 12492)
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: <libc-alpha at sourceware dot org>
- Date: Fri, 28 Jun 2013 17:24:07 +0000
- Subject: Test for mprotect failure in dl-load.c (bug 12492)
This patch, another change that has been in EGLIBC for some time, adds
a check for failure of mprotect in one case in dl-load.c, so fixing
bug 12492. The check and error handling are essentially the same as
on another mprotect call in the same file.
Tested x86_64.
2013-06-28 Pierre Ynard <linkfanel@yahoo.fr>
[BZ #12492]
* elf/dl-load.c (_dl_map_object_from_fd): Test for failure of
mprotect making __stack_prot writable.
diff --git a/elf/dl-load.c b/elf/dl-load.c
index d53ead4..655e38e 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -1487,7 +1487,11 @@ cannot allocate TLS data structures for initial thread");
if (__builtin_expect (p + s <= relro_end, 1))
{
/* The variable lies in the region protected by RELRO. */
- __mprotect ((void *) p, s, PROT_READ|PROT_WRITE);
+ if (__mprotect ((void *) p, s, PROT_READ|PROT_WRITE) < 0)
+ {
+ errstring = N_("cannot change memory protections");
+ goto call_lose_errno;
+ }
__stack_prot |= PROT_READ|PROT_WRITE|PROT_EXEC;
__mprotect ((void *) p, s, PROT_READ);
}
--
Joseph S. Myers
joseph@codesourcery.com