glibc/SOURCES/glibc-rh1817513-42.patch

47 lines
1.8 KiB
Diff
Raw Normal View History

2021-05-18 06:37:04 +00:00
commit 758599bc9dcc5764e862bd9e1613c5d1e6efc5d3
Author: Florian Weimer <fweimer@redhat.com>
Date: Wed Feb 26 15:58:23 2020 +0100
elf: Apply attribute_relro to pointers in elf/dl-minimal.c
The present code leaves the function pointers unprotected, but moves
some of the static functions into .data.rel.ro instead. This causes
the linker to produce an allocatable, executable, writable section
and eventually an RWX load segment. Not only do we really do not
want that, it also breaks valgrind because valgrind does not load
debuginfo from the mmap interceptor if all it sees are RX and RWX
mappings.
Fixes commit 3a0ecccb599a6b1ad4b149dc569c0080e92d057b ("ld.so: Do not
export free/calloc/malloc/realloc functions [BZ #25486]").
diff --git a/elf/dl-minimal.c b/elf/dl-minimal.c
index 95ea7b024044864f..4335f1bd24289b01 100644
--- a/elf/dl-minimal.c
+++ b/elf/dl-minimal.c
@@ -39,16 +39,16 @@
implementation below. Before the final relocation,
__rtld_malloc_init_real is called to replace the pointers with the
real implementation. */
-__typeof (calloc) *__rtld_calloc;
-__typeof (free) *__rtld_free;
-__typeof (malloc) *__rtld_malloc;
-__typeof (realloc) *__rtld_realloc;
+__typeof (calloc) *__rtld_calloc attribute_relro;
+__typeof (free) *__rtld_free attribute_relro;
+__typeof (malloc) *__rtld_malloc attribute_relro;
+__typeof (realloc) *__rtld_realloc attribute_relro;
/* Defined below. */
-static __typeof (calloc) rtld_calloc attribute_relro;
-static __typeof (free) rtld_free attribute_relro;
-static __typeof (malloc) rtld_malloc attribute_relro;
-static __typeof (realloc) rtld_realloc attribute_relro;
+static __typeof (calloc) rtld_calloc;
+static __typeof (free) rtld_free;
+static __typeof (malloc) rtld_malloc;
+static __typeof (realloc) rtld_realloc;
void
__rtld_malloc_init_stubs (void)