Closed sigmaSd closed 1 year ago
also random thaught what about adding integration test like this (is this useful ?)
#[cfg(test)]
mod tests {
#[test]
fn smoke() -> anyhow::Result<()> {
cat()?;
ls()?;
// lurk(&["ls", "-l"])?; // doesn't work yet
Ok(())
}
fn lurk(args: &[&str]) -> anyhow::Result<String> {
let output = std::process::Command::new("cargo")
.arg("r")
.arg("--")
.args(args)
.output()?;
Ok(String::from_utf8(output.stdout)?)
}
fn cat() -> Result<(), anyhow::Error> {
assert!(lurk(&["cat", "/etc/hosts"])?
.lines()
.find(|line| line.contains("openat") && line.contains("/etc/hosts"))
.is_some());
Ok(())
}
fn ls() -> Result<(), anyhow::Error> {
assert!(lurk(&["ls"])?
.lines()
.find(|line| line.contains("openat") && line.contains("\".\""))
.is_some());
Ok(())
}
}
Thanks for opening the issue. I think lurk could definitely use some sort of test suite and I think those integration tests are a great start. I'll check if I can find the problem as soon as I find the time.
This happens because ls -l
uses the epoll_pwait2
syscall. Currently lurk
only supports syscalls from 0 to 334. Newer syscalls defined in the range of 424 - 451 are not handled by lurk
.
if registers.orig_rax >= 336 {
continue;
}
These lines in the run_tracer
function preempt the loop. The tracee is stopped and the parent is unable to issue another PTRACE_SYSCALL
request (here done via ptrace::syscall
at the end of the loop). Hence the tracee hangs indefinitely.
Removing this lines wouldn't matter tho, as the epoll_pwait2
syscall is also not implemented in the x86_64.rs
file.
The gap of syscalls numbers from 334 to 424 is because of the efforts made to sync up syscall numbers between architectures (more info here and here).
Thanks for the explanation
Maybe its better if it crashes, at least it easy to tell what's missing in lurk and even motivate people to add support for missing syscalls
Probably, but I'm in the process of re-writing the main tracing loop for lurk
anyways, not much more work to add the missing 27 syscalls on top of that. Exepect a PR in a few days, I'll make sure to reference this issue as well.
lurk ls
worksbut
lurk ls -l
hangs , the last syscalls before it hangs looks like thisusing gdb I can see its stuck in wait4