@@ -63,19 +63,26 @@ impl VmmapEntry {
63
63
} ;
64
64
}
65
65
66
- // Placeholder method to get maximum protection (currrently incomplete)
67
- fn get_max_prot ( & self , cage_id : u64 , FileDescriptor ( u64 ) ) -> i32 {
68
- let flags = PROT_NONE ;
69
-
70
- flags
71
- }
66
+ // get maximum protection for file based mappings
67
+ // this is effectively whatever mode the file was opened with
68
+ // we need this because we shouldnt be able to change filed backed mappings
69
+ // to have protections exceeding that of the file
70
+ fn get_max_prot ( & self , cage_id : u64 , virtual_fd : u64 -> i32 {
71
+
72
+ let wrappedvfd = fdtables:: translate_virtual_fd ( cage_id, virtual_fd as u64 ) ;
73
+ if wrappedvfd. is_err ( ) {
74
+ return syscall_error ( Errno :: EBADF , "fstat" , "Bad File Descriptor" ) ;
75
+ }
76
+ let vfd = wrappedvfd. unwrap ( ) ;
72
77
78
+ // Declare statbuf by ourselves
79
+ let mut libc_statbuf: stat = unsafe { std:: mem:: zeroed ( ) } ;
80
+ let libcret = unsafe {
81
+ libc:: fstat ( vfd. underfd as i32 , & mut libc_statbuf)
82
+ } ;
73
83
74
- // Placeholder method to check file descriptor protection (currently does nothing)
75
- fn check_fd_protection ( & self , cage_id : i32 ) {
76
- let _ = cage_id;
77
- } // will call the microvisor, need to pass fd
78
- // number if only its files backed and returns flags of fd
84
+ libc_statbuf. mode as i32
85
+ }
79
86
}
80
87
81
88
// VmmapOps trait provides an interface that can be shared by different virtual memory management implementations,
0 commit comments