diff options
author | edef <edef@unfathomable.blue> | 2022-07-30 19:56:58 +0000 |
---|---|---|
committer | edef <edef@unfathomable.blue> | 2022-07-30 20:00:29 +0000 |
commit | 0682ee981a40ee3c549e5a8d62ffd8c6c542ed69 (patch) | |
tree | 6edd09b7b7318407916c10b74febb5fe63e2e3aa | |
parent | bf43a09f7e1c9ce415aee9733741a0cc5b887ea6 (diff) | |
download | unf-legacy-0682ee981a40ee3c549e5a8d62ffd8c6c542ed69.tar.zst |
ripple/minitrace/syscall_abi: represent prlimit64 pid with a unit struct
We don't accept nonzero values here, so we should simply reject those early. Change-Id: I329ae76b1f44f6d3305e710ed8f5f90ee0df988f
-rw-r--r-- | ripple/minitrace/src/main.rs | 10 | ||||
-rw-r--r-- | ripple/minitrace/src/syscall_abi/mod.rs | 26 |
2 files changed, 24 insertions, 12 deletions
diff --git a/ripple/minitrace/src/main.rs b/ripple/minitrace/src/main.rs index 19be3f2..8b82b72 100644 --- a/ripple/minitrace/src/main.rs +++ b/ripple/minitrace/src/main.rs @@ -341,16 +341,6 @@ fn check_syscall(entry: &SyscallEntry) -> bool { } } } - SyscallEntry::prlimit64 { - pid, - resource: _, - new_rlim: _, - old_rlim: _, - } => { - if pid != 0 { - return false; - } - } SyscallEntry::getrandom { ubuf: _, len, diff --git a/ripple/minitrace/src/syscall_abi/mod.rs b/ripple/minitrace/src/syscall_abi/mod.rs index c274d0b..e050711 100644 --- a/ripple/minitrace/src/syscall_abi/mod.rs +++ b/ripple/minitrace/src/syscall_abi/mod.rs @@ -4,7 +4,10 @@ use { crate::{define_syscalls, syscall_bitflags, syscall_enums, Process}, - std::ffi::CString, + std::{ + ffi::CString, + fmt::{self, Debug, Write}, + }, }; pub(crate) use arg::{ProcessSyscallArg, SyscallArg}; @@ -43,7 +46,7 @@ define_syscalls! { fn openat(dfd: DirFd, filename: CString, flags: OpenFlags, mode: FileMode) -> i64 = 257; fn newfstatat(dfd: DirFd, filename: CString, statbuf: *mut Stat, flags: AtFlags) -> i64 = 262; fn set_robust_list(head: *mut RobustListHead, len: RobustListHeadSize) -> i64 = 273; - fn prlimit64(pid: i32, resource: ResourceLimit, new_rlim: *const RLimit64, old_rlim: *mut RLimit64) -> i64 = 302; + fn prlimit64(pid: Zero, resource: ResourceLimit, new_rlim: *const RLimit64, old_rlim: *mut RLimit64) -> i64 = 302; fn getrandom(ubuf: *mut u8, len: usize, flags: GrndFlags) -> i64 = 318; } } @@ -126,6 +129,25 @@ syscall_enums! { } } +#[derive(Copy, Clone)] +pub(crate) struct Zero; + +impl Debug for Zero { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_char('0') + } +} + +impl SyscallArg for Zero { + fn try_from_reg(reg: u64) -> Option<Self> { + if reg == 0 { + Some(Zero) + } else { + None + } + } +} + #[derive(Debug, Copy, Clone)] pub(crate) struct SigSetSize; |