当前位置:   article > 正文

SELinux avc权限--audit2allow_audit2allow命令

audit2allow命令

SELinux avc 权限, audit2allow 使用

若在log出现“ avc:”则按照调试添加权限。

使用avc关键词查找权限相关log
adb logcat -b all | grep "avc:"

进行操作复现问题,抓取最新日志,eg:

05-28 11:41:34.264  7393  7393 I auditd  : type=1400 audit(0.0:383): avc: denied { read } for comm="m.android.email" name="vmstat" dev="proc" ino=4026532351 scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:object_r:proc:s0 tclass=file permissive=0
05-28 11:41:34.264  7393  7393 W m.android.email: type=1400 audit(0.0:383): avc: denied { read } for name="vmstat" dev="proc" ino=4026532351 scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:object_r:proc:s0 tclass=file permissive=0
05-28 11:43:05.454  7696  7696 I auditd  : type=1400 audit(0.0:384): avc: denied { read } for comm="m.android.email" name="vmstat" dev="proc" ino=4026532351 scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:object_r:proc:s0 tclass=file permissive=0
05-28 11:43:05.454  7696  7696 W m.android.email: type=1400 audit(0.0:384): avc: denied { read } for name="vmstat" dev="proc" ino=4026532351 scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:object_r:proc:s0 tclass=file permissive=0
  • 1
  • 2
  • 3
  • 4

创建任意文件,粘贴日志内容,eg:创建文件名称为se.txt,而后使用如下命令:

ubuntu@ubuntu:~$ audit2allow -i se.txt               //很重要的一个以python写的命令,主要用来处理日志,把日志中的违反策略的动作的记录,转换成 access vector
//如果没有该指令,执行安装
sudo apt-get install policycoreutils
  • 1
  • 2
  • 3

得到结果:

#============= untrusted_app_25 ==============
allow untrusted_app_25 proc:file read;
  • 1
  • 2

修改该路径下的文件:/device/qcom/sepolicy/common/ untrusted_app_25.te,在文件添加上述语句:

allow untrusted_app_25 proc:file read;
  • 1

如果没有相似的文件,使用下面查找

grep -rsn "untrusted_app_25" .
///得到结果//
./untrusted_app_25.te:29:hal_client_domain(untrusted_app_25, hal_perf);
./untrusted_app_25.te:32:hal_client_domain(untrusted_app_25, hal_iop);
./untrusted_app_25.te:35:allow untrusted_app_25 vendor_file:file {getattr open read};
./untrusted_app_25.te:38:allow untrusted_app_25 vendor_file:file execute;
./untrusted_app_25.te:41:allow untrusted_app_25 exfat:dir search;
./untrusted_app_25.te:42:allow untrusted_app_25 fuseblk:dir search;
./untrusted_app_25.te:44:allow untrusted_app_25 proc:file read;
///模仿修改/
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

编译 vendorimage、bootimage 验证。

参考链接:
Selinux SeAndroid理解
SELinux audit2allow命令使用

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/49567
推荐阅读
相关标签
  

闽ICP备14008679号