Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --fail-path #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sleirsgoevy
Copy link

No description provided.


struct ChildInfo {
in_syscall: bool,
}

fn decode_syscall_args(regs: libc::user_regs_struct) -> RawSyscall {
fn decode_syscall_args(regs: &libc::user_regs_struct) -> RawSyscall {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needless reference here, because this struct implements Copy.

@@ -21,3 +21,4 @@ anyhow = "1.0.14"
rstack = {version = "0.3.1", default-features = false, features = ["unwind"]}
rustc-demangle = "0.1.16"
cpp_demangle = "0.2.13"
rand = ""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rand = ""
rand = "0.7.3"

@@ -196,6 +199,10 @@ fn main() -> anyhow::Result<()> {
eprintln!("executable not provided");
exit(1);
}
opt.fail_path = match opt.fail_path {
Some(path) => std::fs::canonicalize(path).ok(),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why error is ignored here?

};
children.insert(pid.as_raw() as u32, ci2);
let mut regs = regs;
regs.rax = 39 /*getpid*/;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comments that describe what's happening here

let mut out = RawSyscall {
syscall_id: 0,
args: [0; 6],
ret: 0,
};
out.ret = regs.rax;
out.syscall_id = regs.orig_rax;
out.syscall_id = regs.orig_rax & 0xffffffu64;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still needed?


fn return_eio(pid: Pid, regs: &mut libc::user_regs_struct, syscall: u64) -> Result<(), nix::Error> {
regs.orig_rax = syscall;
regs.rax = -(nix::errno::Errno::EIO as i32 as i64) as u64;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is as i32 portion needed?

let def = magic.lookup_syscall_by_id(SyscallId(params.syscall_id as u32));
let child_pid = Pid::from_raw(pid as i32);
let mut decoded_params = match def {
Some(def) => process_syscall(&params, child_pid, magic, def),
None => None,
};
if started_syscall && decoded_params.is_some() && (params.syscall_id == 2 /*open*/ || params.syscall_id == 257 /*openat*/) { //TODO: x86_64 only
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some comment that describes what this if does.
Also, you should skip this entire if if fail_path is disabled:

if let Some(fail_path) = &setting.fail_path {
   // ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants