You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that the FD opened by a parent process are being closed by frida somehow and therefore not available on the child/target process instrumented by frida itself.
I attached a testcase.zip to demonstrate the issue. The createfd.c just create a file descriptor (1234) by duplicating its stdout and the checkfd.c just checks that such FD is available via fcntl.
If we run those with frida in the middle the checkfd process won't have access at the FD.
$ ./createfd `which frida` --no-pause -q ./checkfd
Running /usr/local/bin/frida...
Spawned `./checkfd`. Resuming main thread!
--- FD 1234 is NOT ready!
I checked the source code and noticed that for darwin when spawning the process the following flag is set: POSIX_SPAWN_CLOEXEC_DEFAULT. According to the documentation:
Apple Extension: If this bit is set, then only file descriptors explicitly described by the file_actions argument are available in the spawned process; all of the other file descriptors are automatically closed in the spawned process.
I immediately thought that this flag was the cause of the issue (why is there btw?).
I patched frida (by removing such flag) and rebuild the framework but I still get the same issue. I then tried to create a "mocked" version of frida where I only start the process the same way it does with posix_spawn and with the very same flags and setup (sigset, fds) and in such case it works:
$ ./createfd ./fridamock ./checkfd
Running ./fridamock...
- [+] FD 1234 ready in fridamock!
- posix_spawn --
- Child pid: 48996
- Child resumed!
--- [+] FD 1234 is READY!
- Child exited with status 0
Can someone please shine some light?
Additional: Frida version 12.7.6
Mac Mojave: 10.14.6
The text was updated successfully, but these errors were encountered:
It seems that the FD opened by a parent process are being closed by frida somehow and therefore not available on the child/target process instrumented by frida itself.
I attached a testcase.zip to demonstrate the issue. The
createfd.c
just create a file descriptor (1234) by duplicating its stdout and thecheckfd.c
just checks that such FD is available viafcntl
.Running the sample directly:
If we run those with frida in the middle the
checkfd
process won't have access at the FD.I checked the source code and noticed that for darwin when spawning the process the following flag is set:
POSIX_SPAWN_CLOEXEC_DEFAULT
. According to the documentation:I immediately thought that this flag was the cause of the issue (why is there btw?).
I patched frida (by removing such flag) and rebuild the framework but I still get the same issue. I then tried to create a "mocked" version of frida where I only start the process the same way it does with
posix_spawn
and with the very same flags and setup (sigset, fds) and in such case it works:Can someone please shine some light?
Additional: Frida version 12.7.6
Mac Mojave: 10.14.6
The text was updated successfully, but these errors were encountered: