summary refs log tree commit diff
path: root/ripple
diff options
context:
space:
mode:
authoredef <edef@unfathomable.blue>2022-07-30 19:34:11 +0000
committeredef <edef@unfathomable.blue>2022-07-30 19:34:11 +0000
commite68fb769a96f0896c92e8c1884a727d3ead47844 (patch)
treef00aba9b30e599b97e9e510d8888486dc277092c /ripple
parent82652914c933f50931338e4bbc924013c358fe71 (diff)
downloadunf-legacy-e68fb769a96f0896c92e8c1884a727d3ead47844.tar.zst
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
Diffstat (limited to 'ripple')
-rw-r--r--ripple/minitrace/src/main.rs12
-rw-r--r--ripple/minitrace/src/syscall_abi/mod.rs15
2 files changed, 14 insertions, 13 deletions
diff --git a/ripple/minitrace/src/main.rs b/ripple/minitrace/src/main.rs
index 74bfee2..2983e57 100644
--- a/ripple/minitrace/src/main.rs
+++ b/ripple/minitrace/src/main.rs
@@ -297,18 +297,6 @@ fn check_syscall(entry: &SyscallEntry) -> bool {
 		SyscallEntry::mprotect { addr, len, prot: _ } => {
 			return addr % 4096 == 0 && len % 4096 == 0;
 		}
-		SyscallEntry::rt_sigaction {
-			sig: _,
-			act: _,
-			oact: _,
-			sigsetsize,
-		} => {
-			if sigsetsize != 8 {
-				panic!(
-					"rt_sigaction(2) sigsetsize should be sizeof (sigset_t), actually {sigsetsize}"
-				);
-			}
-		}
 		SyscallEntry::access { ref filename, mode } => {
 			println!("access({filename:?}, {mode:?})");
 		}
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<FileDesc>, 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<Self> {
+		if reg == 8 {
+			Some(SigSetSize)
+		} else {
+			None
+		}
+	}
+}