libroot: Use getentropy to initialize the stack protector.

Now that it's in libroot, we don't need to invoke the syscall directly.
This commit is contained in:
Augustin Cavalier
2024-07-16 14:16:09 -04:00
parent 4169a972ee
commit 85fb1089de
+2 -10
View File
@@ -8,9 +8,7 @@
#include <signal.h>
#include <stdlib.h>
#include <sys/cdefs.h>
#include <syscalls.h>
#include "private/system/random_defs.h"
#include "private/system/symbol_visibility.h"
@@ -25,14 +23,8 @@ __init_stack_protector()
if (__stack_chk_guard != 0)
return;
struct random_get_entropy_args args;
args.buffer = &__stack_chk_guard;
args.length = sizeof(__stack_chk_guard);
status_t status = _kern_generic_syscall(RANDOM_SYSCALLS, RANDOM_GET_ENTROPY,
&args, sizeof(args));
if (status != B_OK || args.length != sizeof(__stack_chk_guard)) {
int status = getentropy(&__stack_chk_guard, sizeof(__stack_chk_guard));
if (status != 0) {
unsigned char* p = (unsigned char *)&__stack_chk_guard;
p[0] = 0;
p[1] = 0;