Yaxuan-w / RustPOSIX

Rust implementation of SafePOSIX - IMFS
Apache License 2.0
0 stars 0 forks source link

Hook with NaCl #2

Open Yaxuan-w opened 3 months ago

Yaxuan-w commented 3 months ago

When hooking with NaCl and run /hello.nexe, mmap issues:

2806/32017MB    14.96 13.54 13.21 14/1110 1097501   (0) 
[1:0 0:91] 01:41:40 Wed May 01 [lind@ddfc562ab790: +1] ~/lind_project 
@(1:91) $ lind /hello.nexe

executing: [sel_ldr -a -- "runnable-ld.so" --library-path "/lib/glibc" /hello.nexe]
[1097503,4016958592:01:41:46.081080] BYPASSING ALL ACL CHECKS
[1097503,4008478400:01:41:46.083977] NaClSysMmap: MAP_FIXED not fixed: returned 0xffffffffffffffff instead of 0x388611000000
POST-ABORT: LOG_FATAL abort exit

** Signal 6 from trusted code: pc=7f4bef76d32c

Plan to treat as normal read() / write()

Yaxuan-w commented 3 months ago

Nacl will allocate some memory in text segment region, whose permission is denied by default, to run executables (eg: libcgcc_s.so.1). I need to change permission in mmap_syscall. Current solution is:

In mmap_syscall: