SELinux 关于avc:denied {read write getattr xxx} for 错误

环境平台:msm8953、android7.1.2


实例报错:

avc: denied { read write } for pid=3944 comm="handsetpowerlib" name="xxxxx" dev="tmpfs" ino=5545 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:device:s0 tclass=chr_file permissive=1

可得:主体untrusted_app在对客体类别为chr_file、客体为device操作read write时权限不够被拒!

1、为了修改后不会提升其他所有是device类型的设备权限,首先打算修改/dev/xxxxx的类型type,由device改为xxxxx_device,后面只需提升untrusted_app对type为xxxxx_device的设备权限即可。即:

device/qcom/sepolicy/common/device.te增加这个新类型:

type xxxxx_device,dev_type;

device/qcom/sepolicy/common/file_contexts增加定义设备的安全上下文:

/dev/xxxxx  u:object_r:xxxx_device:s0

2、在相应的主体文件device/qcom/sepolicy/common/untrusted_app.te中aloow相应权限:

allow untrusted_app xxxx_device:chr_file { open read write getattr };

3、此时编译测试发现,仍然报错,多半就是MLS检查导致的,需要设置untrusted_app为type充当domain时越过MLS检查,system/sepolicy/untrusted_app.te中修改:

type untrusted_app,domain;为type untrusted_app,domain,mlstrustedsubject;

4、如上,出现了多少avc:denied...就增加多少主体、客体、客体类别对应的allow语句即可。

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值