From e68fb769a96f0896c92e8c1884a727d3ead47844 Mon Sep 17 00:00:00 2001 From: edef Date: Sat, 30 Jul 2022 19:34:11 +0000 Subject: ripple/minitrace/syscall_abi: represent SigSetSize with a unit struct This way we validate the sigsetsize early, and leave the invalid state unrepresentable. Change-Id: I237942089b4eb7fff06ada7ea8be7b8f94b2fcfd --- ripple/minitrace/src/syscall_abi/mod.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'ripple/minitrace/src/syscall_abi') diff --git a/ripple/minitrace/src/syscall_abi/mod.rs b/ripple/minitrace/src/syscall_abi/mod.rs index e0b35a9..6a84679 100644 --- a/ripple/minitrace/src/syscall_abi/mod.rs +++ b/ripple/minitrace/src/syscall_abi/mod.rs @@ -29,7 +29,7 @@ define_syscalls! { fn mmap(addr: u64, len: u64, prot: ProtFlags, flags: MapFlags, fd: Option, off: u64) -> i64 = 9; fn mprotect(addr: u64, len: usize, prot: ProtFlags) -> i64 = 10; fn brk(brk: u64) -> i64 = 12; - fn rt_sigaction(sig: Signal, act: *const SigAction, oact: *mut SigAction, sigsetsize: usize) -> i64 = 13; + fn rt_sigaction(sig: Signal, act: *const SigAction, oact: *mut SigAction, sigsetsize: SigSetSize) -> i64 = 13; fn ioctl(fd: FileDesc, cmd: Ioctl, arg: u64) -> i64 = 16; fn pread64(fd: FileDesc, buf: *mut u8, count: usize, pos: u64) -> i64 = 17; fn access(filename: CString, mode: AccessMode) -> i64 = 21; @@ -125,3 +125,16 @@ syscall_enums! { SEGV = 11 => SIGSEGV, } } + +#[derive(Debug, Copy, Clone)] +pub(crate) struct SigSetSize; + +impl SyscallArg for SigSetSize { + fn try_from_reg(reg: u64) -> Option { + if reg == 8 { + Some(SigSetSize) + } else { + None + } + } +} -- cgit 1.4.1