diff options
author | Ben Wiederhake <BenWiederhake.GitHub@gmx.de> | 2021-11-25 20:15:02 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-12-05 22:59:09 +0100 |
commit | 3e223185b3b6bf96b0b86a3be0ad626193ef85d4 (patch) | |
tree | 33a20a755b99d379404f0652ace88360ccc9cc99 /Kernel/Syscalls | |
parent | 6f37510a710d0a27941eb24b02c920524b0fc19c (diff) | |
download | serenity-3e223185b3b6bf96b0b86a3be0ad626193ef85d4.zip |
Kernel+strace: Remove unnecessary indirection for PEEK
Also, remove incomplete, superfluous check.
Incomplete, because only the byte at the provided address was checked;
this misses the last bytes of the "jerk page".
Superfluous, because it is already correctly checked by peek_user_data
(which calls copy_from_user).
The caller/tracer should not typically attempt to read non-userspace
addresses, we don't need to "hot-path" it either.
Diffstat (limited to 'Kernel/Syscalls')
-rw-r--r-- | Kernel/Syscalls/ptrace.cpp | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/Kernel/Syscalls/ptrace.cpp b/Kernel/Syscalls/ptrace.cpp index adfcef8f70..9547725a33 100644 --- a/Kernel/Syscalls/ptrace.cpp +++ b/Kernel/Syscalls/ptrace.cpp @@ -114,26 +114,18 @@ static ErrorOr<FlatPtr> handle_ptrace(const Kernel::Syscall::SC_ptrace_params& p } case PT_PEEK: { - Kernel::Syscall::SC_ptrace_peek_params peek_params {}; - TRY(copy_from_user(&peek_params, reinterpret_cast<Kernel::Syscall::SC_ptrace_peek_params*>(params.addr))); - if (!Memory::is_user_address(VirtualAddress { peek_params.address })) - return EFAULT; - auto data = TRY(peer->process().peek_user_data(Userspace<const FlatPtr*> { (FlatPtr)peek_params.address })); - TRY(copy_to_user(peek_params.out_data, &data)); + auto data = TRY(peer->process().peek_user_data(Userspace<const FlatPtr*> { (FlatPtr)params.addr })); + TRY(copy_to_user((FlatPtr*)params.data, &data)); break; } case PT_POKE: - if (!Memory::is_user_address(VirtualAddress { params.addr })) - return EFAULT; TRY(peer->process().poke_user_data(Userspace<FlatPtr*> { (FlatPtr)params.addr }, params.data)); return 0; case PT_PEEKDEBUG: { - Kernel::Syscall::SC_ptrace_peek_params peek_params {}; - TRY(copy_from_user(&peek_params, reinterpret_cast<Kernel::Syscall::SC_ptrace_peek_params*>(params.addr))); - auto data = TRY(peer->peek_debug_register(reinterpret_cast<uintptr_t>(peek_params.address))); - TRY(copy_to_user(peek_params.out_data, &data)); + auto data = TRY(peer->peek_debug_register(reinterpret_cast<uintptr_t>(params.addr))); + TRY(copy_to_user((FlatPtr*)params.data, &data)); break; } case PT_POKEDEBUG: |