- SELinux Policy Exception Log 格式.
SELinux Policy Exception 的LOG 关键字是 “avc: denied” 或者 “avc: denied”, 下面就是一句典型的LOG
<5>[ 27.706805] (3)[304:logd.auditd]type=1400 audit(1420041991.220:17): avc: denied { execute } for pid=2182 comm=“app_process” path="/data/dalvik-cache/arm64/system@framework@boot.oat" dev=“mmcblk0p18” ino=15109 scontext=u:r:root_channel:s0 tcontext=u:object_r:dalvikcache_data_file:s0 tclass=file permissive=0
具体说明如下:
<5> : kernel log level
[ 27.706805] : kernel time
(3) : cpu number
[304:logd.auditd] : 表示此LOG 是通过auditd 打印的.
type=1400 : SYSCALL
type=AVC - for kernel events
type=USER_AVC - for user-space object manager events
audit(1420041991.220:17) : audit(time:serial_number)
avc: denied { execute } : field depend on what type of event is being audited.
pid=2182 comm=“app_process” : If a task, then log the process id (pid) and the name of the executable file (comm).
path="/data/dalvik-cache/arm64/system@framework@boot.oat" dev=“mmcblk0p18” ino=15109: The information of target.
subject context : u:r:root_channel:s0
target context : u:object_r:dalvikcache_data_file:s0
tclass : the object class of the target class=system
permissive: permissive (1) or enforcing (0)
- 基本分析流程
1). 将SELinux 调到 permissive mode, 然后一次性抓取出所有的"avc:" 的LOG.
- 如果问题与开机流程无关, 并且eng 版本能够复现.
adb shell setenforce 0 - 如果问题与开机流程相关, 或者只有user build 能够复现. 按下列FAQ 设置permissive mode
2). 确认访问是否是必须的?是否是违法恶意访问?
3). 如果是正常访问, 确认访问的目标类型是否太过广泛,如果太过广泛, 细化具体的文件目标。
4). 添加对应的SELinux Policy 到对应的Policy 文件。
5). 如果是违法恶意访问, 追查上层feature owner 的责任。