1)
I try to process the requests from fileop & vnode scopes in user-mode, so the kernel module waits for the result from the user space application. Let's call the kernel module KauthORamaEx and the user mode application KauthORamaTest.
If I include the KAUTH_FILEOP_EXEC & KAUTH_VNODE_EXECUTE file accesses in the process, KauthORamaTest blocks (cannot process these requests) until the msleep timeout expires (and, of course, the same happens for all the other requests in the meanwhile, resulting in temporary system freezes) . It blocks even if it does only the setsockopt call to release the request (resulting in a wakeup call in the kernel module).
KauthORamaEx is based on KauthORama sample, with the following additions:
- some single-liked tails (queue.h): clients (unit numbers for ctl_getenqueuespace and the PIDs for exclusion), waiting requests
- KauthORamaEx adds the request to the "waiting requests "queue and then waits for KauthORamaTest's answer
KauthORamaTest is also largely based on the same NKE sample code.
Reproduction, 10.5 and 10.6:
- load KauthORamaEx
- add one of the two scopes (Example: sudo sysctl -w kern.com_mycompany_kext_KauthORamaEx="add com.apple.kauth.vnode /usr/bin")
- start KauthORamaTest
- call less (/usr/bin/less)
When it doesn't reproduce:
- KAUTH_FILEOP_EXEC & KAUTH_VNODE_EXECUTE accesses skipped
- KAUTH_VNODE_EXECUTE is combined with KAUTH_VNODE_ACCESS
- KAUTH_FILEOP_EXEC & KAUTH_VNODE_EXECUTE accesses don't pass through msleep
- 10.4
Since Tiger has no problems, I suspect "/private/var/db/dyld/dyld_shared_cache_i386".
I can include the sample if needed.
2)
msleep related question: "Callers of this routine must be prepared for premature return, and check that the reason for sleeping has gone away"
In the sample above, I can check if the reason for return is the user space answer, but how can I see if it is the timeout exit ?
Is EWOULDBLOCK ok ?
3) KauthORama sample has 2 problems
- debug configuration panic on the line: "assert(*actionStrPtr != NULL)"
- it doesn't know about KAUTH_FILEOP_DELETE
Thanks in advance !