Verified Commit 532621cb authored by jD91mZM2's avatar jD91mZM2
Browse files

WIP(ptrace): Test ptrace security

parent 666e28d1
......@@ -132,7 +132,8 @@ pub fn ptrace() -> Result<(), String> {
}
}
println!("Waiting until child is ready to be traced...");
println!("My PID: {}", e(syscall::getpid())?);
println!("Waiting until child (pid {}) is ready to be traced...", pid);
let mut status = 0;
e(syscall::waitpid(pid, &mut status, syscall::WUNTRACED))?;
......@@ -245,6 +246,15 @@ pub fn ptrace() -> Result<(), String> {
assert!(syscall::wifexited(status));
assert_eq!(syscall::wexitstatus(status), 123);
println!("Trying to do illegal things...");
for id in 0..=1_000_000 {
let err = File::open(format!("proc:{}/regs/int", id)).map(|_| None).unwrap_or_else(|err| err.raw_os_error());
assert!(
err == Some(syscall::EPERM) || err == Some(syscall::ESRCH),
"The cops ignored that I tried to illegally open PID {}: {:?}", id, err
);
}
println!("All done and tested!");
Ok(())
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment