Sepolicy在CTS中遇到的问题解决思路
Android5.0的CTS测试中已经包含了安全策略相关的测试项:
runcts -c android.security.cts.SELinuxTest -m testSELinuxPolicyFile
测试中出现了下面的错误信息:
android.security.cts.SELinuxTest#testSELinuxPolicyFile FAIL
查看device_logcat,能看到
System.out: SELinux avc rule neverallow58 failed 2 out of 100 checks.
neverallow58测试出现2个失败,那么这个neverallow58是个啥呢? 先看一下测试的apk,在android cts/
repository/testcases下有个CtsSecurityTestCases.apk,解压缩后asset目录下有个selinux_policy.xml文件,这个文件里面
记录了所有CTS测试项,如下:
<avc_rule name="58" type="neverallow">
<type type="source">kernel</type>
<type type="source">sdcardd</type>
<type type="source">init_shell</type>
… …
<type type="target">security_file</type>
<obj_class name="dir">
<permission>create</permission>
<permission>setattr</permission>
</obj_class>
看来neverallow58就是检查souce定义的这些域中的进程对target类型,也就是security_file类型的目录能否执行create和
setattr操作,当然这是neverallow的,也就是不能执行操作才能pass. 在system/sepolicy目录看看我们最近的修改,发
现为了让init_shell域的进程能够删除/data/security⽬录,修改了domain.te中的neverallow规则:
[external/sepolicy/domain.te]
neverallow { domain -init -system_server -init_shell } security_file:dir { create setattr };
看来neverallow的规则,还是不能随便修改的,否则就可能导致CTS测试失败,去掉init_shell,CTS测试PASS;
[system/sepolicy/domain.te]
neverallow { domain -init -system_server } security_file:dir { create setattr };

浙公网安备 33010602011771号