Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion npm/darwin-arm64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@replit/ruspty-darwin-arm64",
"version": "3.5.2",
"version": "3.5.3",
"os": [
"darwin"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/darwin-x64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@replit/ruspty-darwin-x64",
"version": "3.5.2",
"version": "3.5.3",
"os": [
"darwin"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/linux-x64-gnu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@replit/ruspty-linux-x64-gnu",
"version": "3.5.2",
"version": "3.5.3",
"os": [
"linux"
],
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@replit/ruspty",
"version": "3.5.2",
"version": "3.5.3",
"main": "dist/wrapper.js",
"types": "dist/wrapper.d.ts",
"author": "Szymon Kaliski <hi@szymonkaliski.com>",
Expand Down
28 changes: 23 additions & 5 deletions src/sandbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ struct SyscallTarget {

/// Get the tracee's target path for the syscall that is about to be executed by the kernel.
fn get_syscall_targets(pid: Pid) -> Result<Vec<SyscallTarget>> {
let regs = ptrace::getregs(pid).context("ptrace::getregs")?;
let regs = match ptrace::getregs(pid) {
Ok(regs) => regs,
Err(Error::ESRCH) => return Ok(vec![]), // process gone, no targets
Err(err) => return Err(err).context("ptrace::getregs"),
};
if regs.rax != (-(Error::ENOSYS as i32)) as u64 {
// This is a syscall-exit-stop, and we have already made the decision of allowing / denying the operation.
return Ok(vec![]);
Expand Down Expand Up @@ -483,7 +487,16 @@ fn run_parent(main_pid: Pid, options: &Options) -> Result<i32> {
return Err(err).context("ptrace::setoptions");
}
}
ptrace::syscall(main_pid, None).context("Failed continue process")?;
match ptrace::syscall(main_pid, None) {
Ok(_) => {}
Err(Error::ESRCH) => {
// The child process has already exited.
return Ok(0);
}
Err(err) => {
return Err(err).context("failed to continue process");
}
}

loop {
match wait() {
Expand Down Expand Up @@ -514,16 +527,21 @@ fn run_parent(main_pid: Pid, options: &Options) -> Result<i32> {
}
signum @ Signal::SIGSTOP => {
debug!(signal:?=signum, pid:? = pid; "signal");
ptrace::setoptions(
match ptrace::setoptions(
pid,
ptrace::Options::PTRACE_O_TRACESYSGOOD
| ptrace::Options::PTRACE_O_TRACEFORK
| ptrace::Options::PTRACE_O_TRACEVFORK
| ptrace::Options::PTRACE_O_TRACECLONE
| ptrace::Options::PTRACE_O_EXITKILL
| ptrace::Options::PTRACE_O_TRACEEXIT,
)
.context("setoptions")?;
) {
Ok(_) => {}
Err(Error::ESRCH) => {}
Err(err) => {
return Err(anyhow::Error::new(err).context("setoptions"));
}
}
match ptrace::syscall(pid, None) {
Ok(_) => {}
Err(Error::ESRCH) => {}
Expand Down