当前位置: 代码迷 >> 综合 >> [SELinux Policy]如何设置SELinux策略规则?
  详细解决方案

[SELinux Policy]如何设置SELinux策略规则?

热度:99   发布时间:2024-01-12 20:36:28.0

[SELinux Policy]如何设置SELinux策略规则?

[Description]


android KK 4.4 版本后,Google 默认启用了SELinux, 并会把SELinux 审查异常打印在kernel log
或者 android log(L 版本)中,对应的关键字是: "avc: denied" 或者"avc: denied"
如一行LOG:
<5>[ 17.285600].(0)[503:idmap]type=1400 audit(1356999072.320:202): avc: denied { create
} for pid=503 comm="idmap" name="overlays.list" scontext=u:r:zygote:s0
tcontext=ubject_r:resource_cache_data_file:s0 tclass=file
即表明idmap 这个process, 使用zygote 的source context, 访问/data/resource_cache 目录,并
创建文件时,被SELinux 拒绝访问。


[Keyword]


android, SELinux, avc: denied, audit


[Solution]


KK 版本, Google 只有限制的启用SELinux, 即只有针对netd, installd, zygote, vold 以及它们
直接fork 出的child process 使用enforcing mode, 但不包括zygote fork的普通app.
L 版本, Google 全面开启SELinux, 几乎所有的process 都使enforcing mode, 影响面非常广.
目前所有的SELinux check 失败,在kernel log 或者android log(L版本后)中都有对应的"avc:
denied" 或者 "avc: denied"的LOG 与之对
  相关解决方案