Switch to using AT_RANDOM for the stack guards.
Bug: 7959813
Change-Id: I8db4b8912ba649bfe668c6f22aa44690ddd401a2
diff --git a/libc/bionic/ssp.cpp b/libc/bionic/ssp.cpp
index 08c36c5..f01fee6 100644
--- a/libc/bionic/ssp.cpp
+++ b/libc/bionic/ssp.cpp
@@ -32,15 +32,17 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/auxv.h>
#include <unistd.h>
#include "bionic_ssp.h"
#include "logd.h"
-void* __stack_chk_guard = NULL;
+uintptr_t __stack_chk_guard = NULL;
static void __attribute__((constructor)) __init_stack_check_guard() {
- __stack_chk_guard = __generate_stack_chk_guard();
+ // AT_RANDOM is a pointer to 16 bytes of randomness on the stack.
+ __stack_chk_guard = *reinterpret_cast<uintptr_t*>(getauxval(AT_RANDOM));
}
// This is the crash handler.