summary refs log tree commit diff
path: root/ripple
diff options
context:
space:
mode:
authoredef <edef@unfathomable.blue>2022-07-27 23:28:20 +0000
committeredef <edef@unfathomable.blue>2022-07-27 23:28:20 +0000
commitb22569780d35ee5703ec49c969ea11a2dea02167 (patch)
tree66f3c7af0c3190adb1410b395fb976ab9160e41b /ripple
parentc4531e0286fe8eb2e42480b9483f00eec90279ae (diff)
downloadunf-legacy-b22569780d35ee5703ec49c969ea11a2dea02167.tar.zst
ripple/minitrace: parse mmap flags strictly
Change-Id: I56731f205e065bf501fd31a69c71c10aa7a2f720
Diffstat (limited to 'ripple')
-rw-r--r--ripple/minitrace/src/main.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/ripple/minitrace/src/main.rs b/ripple/minitrace/src/main.rs
index 898490e..9538700 100644
--- a/ripple/minitrace/src/main.rs
+++ b/ripple/minitrace/src/main.rs
@@ -233,7 +233,7 @@ define_syscalls! {
 		fn read(fd: i32, buf: *mut u8, count: usize) -> i64 = 0;
 		fn write(fd: i32, buf: *const u8, count: usize) -> i64 = 1;
 		fn close(fd: i32) -> i64 = 3;
-		fn mmap(addr: u64, len: u64, prot: u64, flags: u64, fd: i32, off: u64) -> i64 = 9;
+		fn mmap(addr: u64, len: u64, prot: u64, flags: MapFlags, fd: i32, off: u64) -> i64 = 9;
 		fn mprotect(addr: u64, len: usize, prot: u64) -> i64 = 10;
 		fn brk(brk: u64) -> i64 = 12;
 		fn rt_sigaction(sig: i32, act: *const SigAction, oact: *mut SigAction, sigsetsize: usize) -> i64 = 13;
@@ -357,10 +357,11 @@ fn check_syscall(process: &Process, entry: SyscallEntry) -> bool {
 			fd,
 			off: _,
 		} => {
-			if fd != !0 {
-				return flags & (libc::MAP_PRIVATE as u64) != 0;
+			if fd == !0 {
+				return flags.contains(MapFlags::ANONYMOUS);
 			} else {
-				return flags & (libc::MAP_ANON as u64) != 0;
+				return flags.intersection(MapFlags::PRIVATE | MapFlags::ANONYMOUS)
+					== MapFlags::PRIVATE;
 			}
 		}
 		SyscallEntry::ioctl { fd: _, cmd, arg: _ } => {
@@ -469,4 +470,11 @@ syscall_bitflags! {
 		const GRND_NONBLOCK = 1 << 0;
 		const GRND_RANDOM = 1 << 1;
 	}
+
+	struct MapFlags: i32 {
+		const PRIVATE   = 1 << 1;
+		const FIXED     = 1 << 4;
+		const ANONYMOUS = 1 << 5;
+		const DENYWRITE = 1 << 11;
+	}
 }