mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 17:58:18 +03:00
Kernel: Use get_fast_random() for the random syscall stack offset
This commit is contained in:
parent
9026598999
commit
f081990717
Notes:
sideshowbarker
2024-07-19 10:23:56 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/f081990717a
@ -1,6 +1,7 @@
|
||||
#include <Kernel/Arch/i386/CPU.h>
|
||||
#include <Kernel/Process.h>
|
||||
#include <Kernel/ProcessTracer.h>
|
||||
#include <Kernel/Random.h>
|
||||
#include <Kernel/Syscall.h>
|
||||
#include <Kernel/VM/MemoryManager.h>
|
||||
|
||||
@ -94,7 +95,7 @@ void syscall_handler(RegisterDump regs)
|
||||
{
|
||||
// Apply a random offset in the range 0-255 to the stack pointer,
|
||||
// to make kernel stacks a bit less deterministic.
|
||||
auto* ptr = (char*)__builtin_alloca(read_tsc() & 0xff);
|
||||
auto* ptr = (char*)__builtin_alloca(get_fast_random<u8>());
|
||||
asm volatile(""
|
||||
: "=m"(*ptr));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user