From 95440d3f5355791632adb389e2c4016b63c8d6c0 Mon Sep 17 00:00:00 2001 From: edef Date: Fri, 29 Jul 2022 21:27:58 +0000 Subject: ripple/minitrace: verify openat mode strictly Change-Id: I943054765b764416ebe031535067dd3631c2ddaf --- ripple/minitrace/src/main.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'ripple/minitrace') diff --git a/ripple/minitrace/src/main.rs b/ripple/minitrace/src/main.rs index 952aaf1..6d5dbc5 100644 --- a/ripple/minitrace/src/main.rs +++ b/ripple/minitrace/src/main.rs @@ -356,7 +356,7 @@ define_syscalls! { fn arch_prctl(option: ArchOption, arg2: u64) -> i64 = 158; fn set_tid_address(tidptr: *mut i32) -> i64 = 218; fn exit_group(error_code: i32) -> i64 = 231; - fn openat(dfd: FileDesc, filename: CString, flags: OpenFlags, mode: u16) -> i64 = 257; + fn openat(dfd: FileDesc, filename: CString, flags: OpenFlags, mode: FileMode) -> i64 = 257; fn newfstatat(dfd: FileDesc, filename: CString, statbuf: *mut Stat, flags: AtFlags) -> i64 = 262; fn set_robust_list(head: *mut RobustListHead, len: usize) -> i64 = 273; fn prlimit64(pid: i32, resource: ResourceLimit, new_rlim: *const RLimit64, old_rlim: *mut RLimit64) -> i64 = 302; @@ -602,6 +602,20 @@ syscall_bitflags! { const W = 1 << 1 => W_OK; const R = 1 << 2 => R_OK; } + + struct FileMode: u32 { + const IRUSR = 0o400 => S_IRUSR; + const IWUSR = 0o200 => S_IWUSR; + const IXUSR = 0o100 => S_IXUSR; + + const IRGRP = 0o040 => S_IRGRP; + const IWGRP = 0o020 => S_IWGRP; + const IXGRP = 0o010 => S_IXGRP; + + const IROTH = 0o004 => S_IROTH; + const IWOTH = 0o002 => S_IWOTH; + const IXOTH = 0o001 => S_IXOTH; + } } syscall_enums! { -- cgit 1.4.1