summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls
diff options
context:
space:
mode:
authorItamar <itamar8910@gmail.com>2020-08-15 10:57:53 +0300
committerAndreas Kling <kling@serenityos.org>2020-08-15 15:06:35 +0200
commit3b422564f3a3283e0c7f5fdf7cadbcd8b86a8878 (patch)
tree0e20742c09d0ec369b25bcb989617cf1f5a7201c /Kernel/Syscalls
parent47d7faa998b933e669747824baa35c908c9c3144 (diff)
downloadserenity-3b422564f3a3283e0c7f5fdf7cadbcd8b86a8878.zip
Kernel: Fix behaviour of PT_TRACEME in ptrace
The behaviour of the PT_TRACEME feature has been broken for some time, this change fixes it. When this ptrace flag is used, the traced process should be paused before exiting execve. We previously were sending the SIGSTOP signal at a stage where interrupts are disabled, and the traced process continued executing normally, without pausing and waiting for the tracer. This change fixes it.
Diffstat (limited to 'Kernel/Syscalls')
-rw-r--r--Kernel/Syscalls/execve.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/Kernel/Syscalls/execve.cpp b/Kernel/Syscalls/execve.cpp
index 93f56ee73a..1f910795f7 100644
--- a/Kernel/Syscalls/execve.cpp
+++ b/Kernel/Syscalls/execve.cpp
@@ -269,6 +269,9 @@ int Process::do_exec(NonnullRefPtr<FileDescription> main_program_description, Ve
// and we don't want to deal with faults after this point.
u32 new_userspace_esp = new_main_thread->make_userspace_stack_for_main_thread(move(arguments), move(environment), move(auxv));
+ if (wait_for_tracer_at_next_execve())
+ Thread::current()->send_urgent_signal_to_self(SIGSTOP);
+
// We enter a critical section here because we don't want to get interrupted between do_exec()
// and Processor::assume_context() or the next context switch.
// If we used an InterruptDisabler that sti()'d on exit, we might timer tick'd too soon in exec().
@@ -557,7 +560,7 @@ int Process::sys$execve(Userspace<const Syscall::SC_execve_params*> user_params)
if (params.arguments.length > ARG_MAX || params.environment.length > ARG_MAX)
return -E2BIG;
- if (m_wait_for_tracer_at_next_execve)
+ if (wait_for_tracer_at_next_execve())
Thread::current()->send_urgent_signal_to_self(SIGSTOP);
String path;
@@ -597,5 +600,4 @@ int Process::sys$execve(Userspace<const Syscall::SC_execve_params*> user_params)
ASSERT(rc < 0); // We should never continue after a successful exec!
return rc;
}
-
}