now that thread pointer is initialized always, ssp canary initialization can be done unconditionally. this simplifies the ldso as it does not try to detect ssp usage, and the init function itself as it is always called exactly once. this also merges ssp init path for shared and static linking.
20 lines
396 B
C
20 lines
396 B
C
#include <string.h>
|
|
#include <stdint.h>
|
|
#include "pthread_impl.h"
|
|
|
|
uintptr_t __stack_chk_guard;
|
|
|
|
void __init_ssp(void *entropy)
|
|
{
|
|
if (entropy) memcpy(&__stack_chk_guard, entropy, sizeof(uintptr_t));
|
|
else __stack_chk_guard = (uintptr_t)&__stack_chk_guard * 1103515245;
|
|
|
|
if (libc.has_thread_pointer)
|
|
__pthread_self()->canary = __stack_chk_guard;
|
|
}
|
|
|
|
void __stack_chk_fail(void)
|
|
{
|
|
a_crash();
|
|
}
|