diff options
author | Brian Gianforcaro <bgianf@serenityos.org> | 2021-05-12 21:44:07 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-13 16:21:53 +0200 |
commit | 956314f0a185729caef7a451ab729e21d37ce02c (patch) | |
tree | ba65c83eed47a358e27038fd1c7b7d159a78f2b6 /Kernel/Syscalls | |
parent | dba261f79bf5b2973d39a2c76e34c84bcf5148af (diff) | |
download | serenity-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.cpp | 4 |
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); |