SELinux avc权限--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

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

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

得到结果:

#============= untrusted_app_25 ==============
allow untrusted_app_25 proc:file read;

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

allow untrusted_app_25 proc:file read;

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

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;
///模仿修改/

编译 vendorimage、bootimage 验证。

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

  • 1
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值