summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls
diff options
context:
space:
mode:
authorBrian Gianforcaro <bgianf@serenityos.org>2021-05-12 21:44:07 -0700
committerAndreas Kling <kling@serenityos.org>2021-05-13 16:21:53 +0200
commit956314f0a185729caef7a451ab729e21d37ce02c (patch)
treeba65c83eed47a358e27038fd1c7b7d159a78f2b6 /Kernel/Syscalls
parentdba261f79bf5b2973d39a2c76e34c84bcf5148af (diff)
downloadserenity-956314f0a185729caef7a451ab729e21d37ce02c.zip
Kernel: Make Process::start_tracing_from API OOM safe
Modify the API so it's possible to propagate error on OOM failure. NonnullOwnPtr<T> is not appropriate for the ThreadTracer::create() API, so switch to OwnPtr<T>, use adopt_own_if_nonnull() to handle creation.
Diffstat (limited to 'Kernel/Syscalls')
-rw-r--r--Kernel/Syscalls/ptrace.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/Kernel/Syscalls/ptrace.cpp b/Kernel/Syscalls/ptrace.cpp
index f380921834..1b9695f410 100644
--- a/Kernel/Syscalls/ptrace.cpp
+++ b/Kernel/Syscalls/ptrace.cpp
@@ -51,7 +51,9 @@ static KResultOr<u32> handle_ptrace(const Kernel::Syscall::SC_ptrace_params& par
if (peer_process.tracer()) {
return EBUSY;
}
- peer_process.start_tracing_from(caller.pid());
+ auto result = peer_process.start_tracing_from(caller.pid());
+ if (result.is_error())
+ return result.error();
ScopedSpinLock lock(peer->get_lock());
if (peer->state() != Thread::State::Stopped) {
peer->send_signal(SIGSTOP, &caller);