1. 关键字 avc: denied
1.1 现象
01-03 10:31:35.585148 331 331 E SELinux : avc: denied { find } for service=xxx_applock pid=5499 uid=10087 scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:object_r:xxx_applock_service:s0 tclass=service_manager permissive=1
1.2 具体参数
E SELinux : avc: denied { find } for
service=xxx_applock
pid=5499
uid=10087
scontext=u:r:untrusted_app_25:s0:c512,c768 表示:subject context : u:r:root_channel:s0
tcontext=u:object_r:xxx_applock_service:s0 表示:target context : u:object_r:dalvikcache_data_file:s0
tclass=service_manager 表示:the object class of the target
permissive=1 表示:permissive (1) or enforcing (0)
- 缺少什么权限: 缺少 find 权限
- 哪个te文件缺少权限: scontext=u:r:untrusted_app_25:s0:c512,c768,
- 具体哪个文件缺少权限: tcontext=u:object_r:xxx_applock_service:s0
- 什么类型的文件: class=service_manager
上述解释如下:
- avc: denied { find } for ,表示缺少 find 权限
- scontext=u:r:untrusted_app_25:s0:c512,c768,表示 untrusted_app_25.te 缺少该权限
- tcontext=u:object_r:xxx_applock_service:s0, 表示untrusted_app_25.te 缺少对 xxx_applock_service 的权限
- tclass=service_manager 权限文件类型
即总结为:untrusted_app_25.te 文件需要新增类型为service_manager 的 xxx_applock_service 的 find 权限
2. SELinux 相关设置文件
2.1 线索
线索:
- 权限文件:scontext=u:r:untrusted_app_25:s0:c512,c768
- 具体权限内容:tcontext=u:object_r:xxx_applock_service:s0
- 权限类型:tclass=service_manager
2.2 思路
在所有 untrusted_app_25.te 文件中新增如下语句
allow untrusted_app_25 xxx_applock_service:service_manager { find };
2.3 查找 te 文件
查找 untrusted_app_25.te 所在位置
root@69959bbb90c6:/home/suhuazhi/8.1/liangxiang# find system/sepolicy/ -name "untrusted_app_25.te"
system/sepolicy/prebuilts/api/26.0/private/untrusted_app_25.te
system/sepolicy/prebuilts/api/26.0/public/untrusted_app_25.te
system/sepolicy/private/untrusted_app_25.te
system/sepolicy/public/untrusted_app_25.te
2.4 修改 te 文件,添加 tclass=service_manager
- system/sepolicy/prebuilts/api/26.0/private/untrusted_app_25.te
allow untrusted_app_25 xxx_applock_service:service_manager { find };
- system/sepolicy/prebuilts/api/26.0/public/untrusted_app_25.te
allow untrusted_app_25 xxx_applock_service:service_manager { find };
- system/sepolicy/private/untrusted_app_25.te
allow untrusted_app_25 xxx_applock_service:service_manager { find };
- system/sepolicy/public/untrusted_app_25.te
allow untrusted_app_25 xxx_applock_service:service_manager { find };