mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:57:44 +00:00
Kernel: Add 'ptrace' syscall
This commit adds a basic implementation of the ptrace syscall, which allows one process (the tracer) to control another process (the tracee). While a process is being traced, it is stopped whenever a signal is received (other than SIGCONT). The tracer can start tracing another thread with PT_ATTACH, which causes the tracee to stop. From there, the tracer can use PT_CONTINUE to continue the execution of the tracee, or use other request codes (which haven't been implemented yet) to modify the state of the tracee. Additional request codes are PT_SYSCALL, which causes the tracee to continue exection but stop at the next entry or exit from a syscall, and PT_GETREGS which fethces the last saved register set of the tracee (can be used to inspect syscall arguments and return value). A special request code is PT_TRACE_ME, which is issued by the tracee and causes it to stop when it calls execve and wait for the tracer to attach.
This commit is contained in:
parent
c9396be83f
commit
6b74d38aab
13 changed files with 300 additions and 102 deletions
|
@ -133,7 +133,6 @@ namespace Kernel {
|
|||
__ENUMERATE_SYSCALL(donate) \
|
||||
__ENUMERATE_SYSCALL(rename) \
|
||||
__ENUMERATE_SYSCALL(ftruncate) \
|
||||
__ENUMERATE_SYSCALL(systrace) \
|
||||
__ENUMERATE_SYSCALL(exit_thread) \
|
||||
__ENUMERATE_SYSCALL(mknod) \
|
||||
__ENUMERATE_SYSCALL(writev) \
|
||||
|
@ -182,7 +181,8 @@ namespace Kernel {
|
|||
__ENUMERATE_SYSCALL(unveil) \
|
||||
__ENUMERATE_SYSCALL(perf_event) \
|
||||
__ENUMERATE_SYSCALL(shutdown) \
|
||||
__ENUMERATE_SYSCALL(get_stack_bounds)
|
||||
__ENUMERATE_SYSCALL(get_stack_bounds) \
|
||||
__ENUMERATE_SYSCALL(ptrace)
|
||||
|
||||
namespace Syscall {
|
||||
|
||||
|
@ -424,6 +424,13 @@ struct SC_stat_params {
|
|||
bool follow_symlinks;
|
||||
};
|
||||
|
||||
struct SC_ptrace_params {
|
||||
int request;
|
||||
pid_t pid;
|
||||
u8* addr;
|
||||
int data;
|
||||
};
|
||||
|
||||
void initialize();
|
||||
int sync();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue