参考:Android SELinux avc dennied权限问题解决方法
解决原则:缺什么权限补什么,直到没有avc denied为止。
解决方法:在对应的.te中增加allow语句。
格式一般如下:
avc: denied { 操作权限 } for pid=7201 comm=“进程名” scontext=u:r:源类型:s0 tcontext=u:r:目标类型:s0 tclass=访问类型 permissive=0
案例:
audit: type=1400 audit(1113.763:288): avc: denied { write } for pid=328 comm="fastbootd" name="mmcblk0p29" dev="tmpfs" ino=7915 scontext=u:r:fastbootd:s0 tcontext=u:object_r:mmcblk_device:s0 tclass=blk_file permissive=1
scontext和tcontext都是安全上下文,分别称为主体和客体,主体一般都是进程,客体则是主体访问的资源。
缺少什么权限: { write }权限,
谁缺少权限: scontext=u:r:fastbootd:s0
对哪个资源缺少权限: tcontext=u:object_r:mmcblk_device:s0
什么类型的资源: tclass=blk_file
完整的意思: fastbootd进程对mmcblk_device类型的blk_file缺少write权限。
解决方法:在fastbootd.te文件(若没有则添加)加入内容:
allow fastbootd mmcblk_device:blk_file { read write getattr open ioctl };
即允许fastbootd对mmcblk_device类型的blk_file进行read/write/ioctl等操作。