avc: denied SELinux权限问题解决

2023-05-16

1. SELinux简介

SELinux是Google从android 5.0开始,强制引入的一套非常严格的权限管理机制,主要用于增强系统的安全性。然而,在开发中,我们经常会遇到由于SELinux造成的各种权限不足,即使拥有“万能的root权限”,也不能获取全部的权限。

2. 调试确认SELinux问题

为了澄清是否因为SELinux导致的问题,可先执行:
setenforce 0 (临时禁用掉SELinux)
getenforce (得到结果为Permissive)
如果问题消失了,基本可以确认是SELinux造成的权限问题,需要通过正规的方式来解决权限问题。

3. 万能解决方案

报错log:

报错log:
 avc: denied { read } for name="u:object_r:hwservicemanager_prop:s0" dev="tmpfs" ino=20968 scontext=u:r:hal_secure_element_unisoc:s0 tcontext=u:object_r:hwservicemanager_prop:s0 tclass=file permissive=0
 
可以看到有avc denied,且最后有permissive=0,表示不允许。

分析过程:

avc: denied { read } for name=“u:object_r:hwservicemanager_prop:s0” dev=“tmpfs” ino=20968 scontext=u:r:hal_secure_element_unisoc:s0 tcontext=u:object_r:hwservicemanager_prop:s0 tclass=file permissive=0

缺少什么权限:     { read }权限,
谁缺少权限:        scontext=u:r:hal_secure_element_unisoc:s0 
对哪个文件缺少权限:tcontext=u:object_r:hwservicemanager_prop
什么类型的文件:  tclass=file 
完整的意思: hal_secure_element_unisoc进程对hwservicemanager_prop类型的file缺少read 权限。

解决方法:在上文A位置,找到kernel.te这个文件,加入以下内容:

allow  hal_secure_element_unisoc hwservicemanager_prop:file  read;

make installclean后重新编译,刷boot.img才会生效。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

avc: denied SELinux权限问题解决 的相关文章

随机推荐