diff options
author | edef <edef@unfathomable.blue> | 2022-07-29 21:02:45 +0000 |
---|---|---|
committer | edef <edef@unfathomable.blue> | 2022-07-29 21:02:45 +0000 |
commit | b9227791ce67f4f032b735bbcfb2e8df6f34bb70 (patch) | |
tree | 4b41c097ff2be1cca533da824ea012bb72f80c75 /ripple | |
parent | b11be552627c0f958cc60c574e9b75c785141838 (diff) | |
download | unf-legacy-b9227791ce67f4f032b735bbcfb2e8df6f34bb70.tar.zst |
ripple/minitrace: verify access(2) mode strictly
Change-Id: I5e9f300a6db5fd40b2d46679ae6e613c1352a899
Diffstat (limited to 'ripple')
-rw-r--r-- | ripple/minitrace/src/main.rs | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/ripple/minitrace/src/main.rs b/ripple/minitrace/src/main.rs index fce614d..e7da54e 100644 --- a/ripple/minitrace/src/main.rs +++ b/ripple/minitrace/src/main.rs @@ -134,10 +134,11 @@ fn libc_check<T: Debug + Eq + fmt::LowerHex>( (our_name, our_value): (&'static str, T), (libc_name, libc_value): (&'static str, T), ) { - assert!( - libc_name.ends_with(our_name), - "{libc_name} doesn't end with {our_name}" - ); + match () { + _ if libc_name.ends_with(our_name) => {} + _ if libc_name.starts_with(&format!("{our_name}_")) => {} + () => panic!("{libc_name} doesn't match {our_name}"), + } assert!( our_value == libc_value, @@ -347,7 +348,7 @@ define_syscalls! { fn rt_sigaction(sig: i32, act: *const SigAction, oact: *mut SigAction, sigsetsize: usize) -> 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: i32) -> i64 = 21; + fn access(filename: CString, mode: AccessMode) -> i64 = 21; fn getcwd(buf: *mut u8, size: u64) -> i64 = 79; fn readlink(path: CString, buf: *mut u8, bufsiz: i32) -> i64 = 89; fn sysinfo(info: *mut SysInfo) -> i64 = 99; @@ -477,11 +478,8 @@ fn check_syscall(entry: &SyscallEntry) -> bool { SyscallEntry::mprotect { addr, len, prot: _ } => { return addr % 4096 == 0 && len % 4096 == 0; } - SyscallEntry::access { - ref filename, - mode: _, - } => { - println!("access({filename:?}, ..)"); + SyscallEntry::access { ref filename, mode } => { + println!("access({filename:?}, {mode:?})"); } SyscallEntry::readlink { ref path, @@ -585,6 +583,13 @@ syscall_bitflags! { struct AtFlags: i32 { const EMPTY_PATH = 1 << 12 => AT_EMPTY_PATH; } + + struct AccessMode: i32 { + const F = 0 => F_OK; + const X = 1 << 0 => X_OK; + const W = 1 << 1 => W_OK; + const R = 1 << 2 => R_OK; + } } syscall_enums! { |