audit(0.0:67): avc: denied { write } for path="/dev/block/vold/93:96" dev="tmpfs" ino=/1263 scontext=u:r:kernel:s0 tcontext=u:object_r:block_device:s0 tclass=blk_file permissive=0
分析过程:
缺少什么权限: { write }权限,
谁缺少权限: scontext=u:r:kernel:s0
对哪个文件缺少权限:tcontext=u:object_r:block_device
什么类型的文件: tclass=blk_file
完整的意思: kernel进程对block_device类型的blk_file缺少write权限。
解决方法:
在上文A位置,找到kernel.te这个文件,加入以下内容:
allow kernel block_device:blk_file write;
make installclean后重新编译,刷boot.img才会生效。
案例2
audit(0.0:53): avc: denied { execute } for path="/data/data/com.mofing/qt-reserved-files/plugins/platforms/libgnustl_shared.so" dev="nandl" ino=115502 scontext=u:r:platform_app:s0 tcontext=u:object_r:app_data_file:s0 tclass=file permissive=0
分析过程:
缺少什么权限: { execute}权限,
谁缺少权限: scontext = u:r:platform_app:s0
对哪个文件缺少权限:tcontext = u:object_r:app_data_file
什么类型的文件: tclass= file
完整的意思: platform_app进程对app_data_file类型的file缺少execute权限。
解决方法:在上文A位置,找到platform_app.te这个文件,加入以下内容:
allow platform_app app_data_file:file execute;
案例3
audit(1444651438.800:8): avc: denied { search } for pid=158 comm="setmacaddr" name="/" dev="nandi" ino=1 scontext=u:r:engsetmacaddr:s0 tcontext=u:object_r:vfat:s0 tclass=dir permissive=0
解决方法 :
allow engsetmacaddr vfat:dir { search write add_name create }; 或者
allow engsetmacaddr vfat:dir create_dir_perms;
案例4
audit(1441759284.810:5): avc: denied { read } for pid=1494 comm="sdcard" name="0" dev="nandk" ino=245281 scontext=u:r:sdcardd:s0 tcontext=u:object_r:system_data_file:s0 tclass=dir permissive=0
解决方法
allow sdcardd system_data_file:dir read; 或者
allow sdcardd system_data_file:dir rw_dir_perms;
以第案例4为例:
audit(1441759284.810:5): avc: denied { read } for pid=1494 comm="sdcard" name="0" dev="nandk" ino=245281 scontext=u:r:sdcardd:s0 tcontext=u:object_r:system_data_file:s0 tclass=dir permissive=0
某个scontext对某个tclass类型的tcontext缺乏某个权限,我们需要允许这个权限:
我们的log重新排列一下,
scontext = u:r:sdcardd
tcontex t= u:object_r:system_data_file:s0
tclass = dir
avc: denied { read }
得到万能套用公式如下:
在scontext所指的.te文件(例如sdcardd.te)中加入类似如下allowe内容:
参考文档:https://blog.csdn.net/m0_37905055/article/details/100689474?utm_medium=distribute.pc_relevant.none-task-blog-2defaultbaidujs_title~default-0.no_search_link&spm=1001.2101.3001.4242