Question
Hi All,
I'm working on a summer project for IBM research, and we're interested in gathering forensic information on misbehaving processes.
Consider the case when a process is trying to do something it shouldn't, SELinux steps in, denies the read/write/whatever request, and then prints out an error message.
What we'd like to be able to do, is to freeze the process right before the read/write request gets rejected.. and then call a script, which can gather some forensic information on the process.
It's important for us to be able to do this -before- the process's request is rejected.
I don't think theres anything in place right now to do this (or am I wrong?), but could someone please let me know how difficult it would be to add this, and where the code would have to go?
Ideally, we'd like to do a kill -s SIGSTOP on the process, and then run a script (passing in the misbehaving pid).
Thanks in advance,
Chris
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 7 lines · Christopher Soghoian
What we'd like to be able to do, is to freeze the process right before the read/write request gets rejected.. and then call a script, which can gather some forensic information on the process.
It's important for us to be able to do this -before- the process's request is rejected.
Quoted 6 lines
I don't think theres anything in place right now to do this (or am I wrong?), but could someone please let me know how difficult it would be to add this, and where the code would have to go?
Ideally, we'd like to do a
kill -s SIGSTOPon the process, and then run a script (passing in the misbehaving pid).
You would need to be selective in the set of permission checks that triggered such behavior, as some permissions checks are called at points where it would not be safe for you to block in this manner (e.g. kernel locks may be held, or you may not even be in process context). You could introduce an additional access vector for this purpose, similar to the existing vectors that control the auditing behavior. You could then modify avc_has_perm_noaudit() to (after releasing its own lock) call force_sig_specific(SIGSTOP, current) if a) in process context, and b) the requested permissions were denied, and c) the denied permissions were present in the new vector, and to then call call_usermodehelper() to run your script. Or you could do likewise in specific hook functions, e.g. selinux_inode_permission(), if you only wanted to apply such behavior to specific hooks.
Signature · 8 lines
Stephen Smalley <[email protected]> National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.