summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-01-09 15:42:03 +0100
committerAndreas Kling <kling@serenityos.org>2021-01-09 15:42:03 +0100
commit8ff0afd829a54f067ce63cf6e443aae95124ac6b (patch)
treebd4a75e44572e8007fb91eacb8bd7cd6800ce621
parente08e1a89d9cd65d9537948795b27a075e63366f3 (diff)
downloadserenity-8ff0afd829a54f067ce63cf6e443aae95124ac6b.zip
Kernel: Defer switching the paging scope in ptrace(PT_POKE) a little
If we can fail with EFAULT early, might as well avoid switching the paging scope.
-rw-r--r--Kernel/Syscalls/ptrace.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/Kernel/Syscalls/ptrace.cpp b/Kernel/Syscalls/ptrace.cpp
index ccc585a511..81ea5e6cf0 100644
--- a/Kernel/Syscalls/ptrace.cpp
+++ b/Kernel/Syscalls/ptrace.cpp
@@ -72,11 +72,11 @@ KResultOr<u32> Process::peek_user_data(Userspace<const u32*> address)
KResult Process::poke_user_data(Userspace<u32*> address, u32 data)
{
- ProcessPagingScope scope(*this);
Range range = { VirtualAddress(address), sizeof(u32) };
auto* region = find_region_containing(range);
if (!region)
return KResult(-EFAULT);
+ ProcessPagingScope scope(*this);
if (region->is_shared()) {
// If the region is shared, we change its vmobject to a PrivateInodeVMObject
// to prevent the write operation from changing any shared inode data
@@ -97,11 +97,11 @@ KResult Process::poke_user_data(Userspace<u32*> address, u32 data)
});
if (!copy_to_user(address, &data)) {
- dbg() << "Invalid address for poke_user_data: " << address.ptr();
+ dbgln("poke_user_data: Bad address {:p}", address.ptr());
return KResult(-EFAULT);
}
- return KResult(KSuccess);
+ return KSuccess;
}
}