-
Notifications
You must be signed in to change notification settings - Fork 3
Description
In your recent Reddit post (https://www.reddit.com/r/rust/comments/1kocais/crate_update_how_to_block_or_intercept_specific/), I noticed this part:
the way syscalls enum is generated depends on your linux system because it parses your system headers at build time and it's prone to failure in some linux systems, so i would love to hear your feedback on this.
I maintain the crate linux-syscall, which contains a list of syscall numbers and a syscall!() macro for invoking them. The syscall numbers are generated separately and are checked in to source control, so there's no additional build step. My primary use case is the syscall!() macro, so I haven't thought about using it just as a source of syscall numbers until now.
If I were to update that crate to (1) add syscall number coverage for architectures without asm!() and (2) add a const method to extract the raw syscall number from the Syscall struct, would that be of any use to the restrict crate?
The example code would look something like this:
use linux_syscall as syscall;
use restrict::Policy;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Begin with everything allowed
let mut policy = Policy::allow_all()?;
// Block process creation and tracing
policy
.deny(syscall::SYS_execve)
.deny(syscall::SYS_ptrace)
.apply()?; // Load the final rule set into the kernel
// Your program continues here with the policy enforced
Ok(())
}