From 85fb1089dec6e9b358b70a35fe7cff31bbbe3949 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Tue, 16 Jul 2024 14:16:09 -0400 Subject: [PATCH] libroot: Use getentropy to initialize the stack protector. Now that it's in libroot, we don't need to invoke the syscall directly. --- src/system/libroot/os/stack_protector.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/system/libroot/os/stack_protector.cpp b/src/system/libroot/os/stack_protector.cpp index d441d03cb9..c8a26c1017 100644 --- a/src/system/libroot/os/stack_protector.cpp +++ b/src/system/libroot/os/stack_protector.cpp @@ -8,9 +8,7 @@ #include #include #include -#include -#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;