diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-11-29 16:15:30 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-11-29 16:30:05 +0100 |
commit | e56daf547c120adfcdab1e1e8ea189a1f369bd0c (patch) | |
tree | 89d1aac5b5ccdc6c0aa25b735a351b5623b6f139 /Userland/crash.cpp | |
parent | ea52fe528a1b34590661c4556b6a4bbf68bb75f0 (diff) | |
download | serenity-e56daf547c120adfcdab1e1e8ea189a1f369bd0c.zip |
Kernel: Disallow syscalls from writeable memory
Processes will now crash with SIGSEGV if they attempt making a syscall
from PROT_WRITE memory.
This neat idea comes from OpenBSD. :^)
Diffstat (limited to 'Userland/crash.cpp')
-rw-r--r-- | Userland/crash.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Userland/crash.cpp b/Userland/crash.cpp index fa6f6e9b3e..7879cda844 100644 --- a/Userland/crash.cpp +++ b/Userland/crash.cpp @@ -1,4 +1,5 @@ #include <AK/String.h> +#include <Kernel/Syscall.h> #include <stdio.h> #include <stdlib.h> #include <sys/mman.h> @@ -24,6 +25,7 @@ int main(int argc, char** argv) WriteToReadonlyMemory, InvalidStackPointerOnSyscall, InvalidStackPointerOnPageFault, + SyscallFromWritableMemory, }; Mode mode = SegmentationViolation; @@ -52,6 +54,8 @@ int main(int argc, char** argv) mode = InvalidStackPointerOnSyscall; else if (String(argv[1]) == "-t") mode = InvalidStackPointerOnPageFault; + else if (String(argv[1]) == "-S") + mode = SyscallFromWritableMemory; else print_usage_and_exit(); @@ -152,6 +156,11 @@ int main(int argc, char** argv) ASSERT_NOT_REACHED(); } + if (mode == SyscallFromWritableMemory) { + u8 buffer[] = { 0xb8, Syscall::SC_getuid, 0, 0, 0, 0xcd, 0x82 }; + ((void(*)())buffer)(); + } + ASSERT_NOT_REACHED(); return 0; } |