android selinux

1.涉及文件

android/device/qcom/sepolicy/common/*.te
android/external/sepolicy/*.te



2.检查是否为selinux权限问题

seteforce 0 // 关闭selinux

在 seteforce 0 的情况下抓取logcat 过滤关键字 avc
logcat |grep avc


W/vold    (  338): type=1400 audit(0.0:34): avc: denied { create } for name="smdl76259125.tmp.asec" scontext=u:r:vold:s0 tcontext=u:object_r:vold_tmpfs:s0 tclass=file
W/vold    (  338): type=1400 audit(0.0:35): avc: denied { open } for name="smdl76259125.tmp.asec" dev="tmpfs" ino=24405 scontext=u:r:vold:s0 tcontext=u:object_r:vold_tmpfs:s0 tclass=file
W/vold    (  338): type=1400 audit(0.0:36): avc: denied { getattr } for path="/mnt/secure/asec/smdl76259125.tmp.asec" dev="tmpfs" ino=24405 scontext=u:r:vold:s0 tcontext=u:object_r:vold_tmpfs:s0 tclass=file
W/vold    (  338): type=1400 audit(0.0:37): avc: denied { rename } for name="smdl76259125.tmp.asec" dev="tmpfs" ino=24405 scontext=u:r:vold:s0 tcontext=u:object_r:vold_tmpfs:s0 tclass=file
W/m.android.phone( 1148): type=1400 audit(0.0:38): avc: denied { getattr } for path="/mnt/asec/com.baidu.appsearch-2/base.apk" dev="dm-0" ino=12 scontext=u:r:radio:s0 tcontext=u:object_r:asec_apk_file:s0 tclass=file
W/m.android.phone( 1148): type=1400 audit(0.0:39): avc: denied { read } for name="base.apk" dev="dm-0" ino=12 scontext=u:r:radio:s0 tcontext=u:object_r:asec_apk_file:s0 tclass=file
W/m.android.phone( 1148): type=1400 audit(0.0:40): avc: denied { open } for name="base.apk" dev="dm-0" ino=12 scontext=u:r:radio:s0 tcontext=u:object_r:asec_apk_file:s0 tclass=file
W/installd(  257): type=1400 audit(0.0:41): avc: denied { getattr } for path="/mnt/secure/asec/com.baidu.appsearch-2.asec" dev="tmpfs" ino=24405 scontext=u:r:installd:s0 tcontext=u:object_r:vold_tmpfs:s0 tclass=file


3.工具转换

audit2allow -i avc.txt -o avc.te

#============= installd ==============
4 allow installd vold_tmpfs:file getattr;
5
6 #============= radio ==============
7 allow radio asec_apk_file:file { read getattr open };
8
9 #============= vold ==============
10 allow vold vold_tmpfs:file { rename create open getattr };



4.权限解析

W/vold ( 338): type=1400 audit(0.0:34): avc: denied { create } for name=”smdl76259125.tmp.asec” scontext=u:r:vold:s0 tcontext=u:object_r:vold_tmpfs:s0 tclass=file

denied 表示权限 u表示进程 object_r 表示文件

5.常见问题

5.1 file_context需整编system

5.2
testAospSeappContexts/testAospFil
eContexts/testAospPropertyContexts/testAosp
ServiceContexts fail的解决方案
[DESCRIPTION]
android.cts.security.SELinuxHostTest 中有一类cases,比如
testAospSeappContexts/testAospFileContexts/testAospPropertyContexts/testAospServiceCont
exts
会去验证原生的/external/sepolicy/XXX_contexts有没有被修改过,若内容有修改,一定会fail,报
错类似于下面这样

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值