Revert "stack protector: use AT_RANDOM"
The AT_RANDOM changes broke setuid / setgid executables
such as "ping". When the linker executes a setuid program,
it cleans the environment, removing any invalid environment
entries, and adding "NULL"s to the end of the environment
array for each removed variable. Later on, we try to determine
the location of the aux environment variable, and get tripped
up by these extra NULLs.
Reverting this patch will get setuid executables working again,
but getauxval() is still broken for setuid programs because of
this bug.
This reverts commit e3a49a8661125f24aec8a1453e54b3b78005e21e.
Change-Id: I05c58a896b1fe32cfb5d95d43b096045cda0aa4a
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 120f9ee..0a89b72 100755
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -1785,7 +1785,7 @@
* fixed it's own GOT. It is safe to make references to externs
* and other non-local data at this point.
*/
-static unsigned __linker_init_post_relocation(uintptr_t* elfdata, unsigned linker_base)
+static unsigned __linker_init_post_relocation(unsigned **elfdata, unsigned linker_base)
{
static soinfo linker_soinfo;
@@ -1976,7 +1976,7 @@
* Find the value of AT_BASE passed to us by the kernel. This is the load
* location of the linker.
*/
-static unsigned find_linker_base(uintptr_t* elfdata) {
+static unsigned find_linker_base(unsigned **elfdata) {
int argc = (int) *elfdata;
char **argv = (char**) (elfdata + 1);
unsigned *vecs = (unsigned*) (argv + argc + 1);
@@ -2032,8 +2032,8 @@
* relocations, any attempt to reference an extern variable, extern
* function, or other GOT reference will generate a segfault.
*/
-extern "C" unsigned __linker_init(uintptr_t* elfdata) {
- uintptr_t linker_addr = find_linker_base(elfdata);
+extern "C" unsigned __linker_init(unsigned **elfdata) {
+ unsigned linker_addr = find_linker_base(elfdata);
Elf32_Ehdr *elf_hdr = (Elf32_Ehdr *) linker_addr;
Elf32_Phdr *phdr =
(Elf32_Phdr *)((unsigned char *) linker_addr + elf_hdr->e_phoff);