From b22569780d35ee5703ec49c969ea11a2dea02167 Mon Sep 17 00:00:00 2001 From: edef Date: Wed, 27 Jul 2022 23:28:20 +0000 Subject: ripple/minitrace: parse mmap flags strictly Change-Id: I56731f205e065bf501fd31a69c71c10aa7a2f720 --- ripple/minitrace/src/main.rs | 16 ++++++++++++---- 1 file 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; + } } -- cgit 1.4.1