A short primer for Android hackers
$ ps -Z
u:r:zygote:s0 root 2981 1 zygote
u:r:untrusted_app:s0 u0_a114 9901 2981 com.instagram.android
$ ls -Z /data/data | grep instagram
drwxr-x--x u0_a114 u0_a114 u:object_r:app_data_file:s0 com.instagram.android
type mediaserver, domain;
class fifo_file
class fifo_file
inherits file
{
open
audit_access
execmod
}
allow mediaserver appdomain:fifo_file { getattr read write }; | | | | source target class permissions
You typically discover which ones are needed through audit logs:
$ adb logcat | grep permissive=0
E/audit ( 5289): type=1400 msg=audit(1440766358.544:45217): avc:
denied { read } for pid=4731 comm="mediaserver" path="/foo/fifo"
scontext=u:r:mediaserver:s0 tcontext=u:r:appdomain:s0 tclass=fifo_file
permissive=0
aka “rules”
Applied to classes:
mlsconstrain fifo_file { read getattr }
(l1 dom l2 or t1 == mlstrustedsubject or t2 == mlstrustedobject or t2 == domain);
$ git clone https://android.googlesource.com/platform/external/sepolicy