Android O selinux违反Neverallow解决办法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yxw0609131056/article/details/79784490

因工作需要移植fastmmi到Android O,其中会涉及selinux权限配置,现将自己的理解总结如下:

1、Android O selinux相关配置文件所在路径

      system/sepolicy/*                      AOSP device和APPS相关selinux配置

      device/qcom/sepolicy/*            平台和板卡相关selinux配置

2、修改selinux权限时,注意不要违反谷歌规定的Neverallow规则,否则编译报错

例如:kernel log中提示“avc: denied { read write } for pid=867 comm="mmi" name="binder" dev="tmpfs" ino=10501 scontext=u:r:mmi:s0 tcontext=u:object_r:binder_device:s0 tclass=chr_file permissive=0”

如果直接在mmi.te文件中添加:allow mmi  binder_device : chr_file  rw_file_perms,就可能导致违反谷歌规定的Neverallow规则而编译报错: 

system/sepolicy/public/domain.te

neverallow {
  domain
  -coredomain
  -appdomain
  -binder_in_vendor_violators 

} binder_device:chr_file rw_file_perms;

如果这时直接修改neverallow规则,可以通过编译,但是可能会导致CTS测试失败,所以这时就要想办法绕过neverallow规则,

上面有一个binder_in_vendor_violators貌似和binder有关,那我们就先看下这个东东如何定义的吧?

system/sepolicy/public/attributes

attribute binder_in_vendor_violators;

expandattribute binder_in_vendor_violators false;

system/sepolicy/private/binder_in_vendor_violators.te

allow binder_in_vendor_violators binder_device:chr_file rw_file_perms;

从中可以看出这个东东具有读写binder_device权限,那我们能否利用这个?如果可以,又该如何利用?

 其实很简单,只要做如下修改即可:

device/qcom/sepolicy/common/mmi.te

typeattribute mmi binder_in_vendor_violators;

将mmi domain关联到这个东东,问题就可以解决了

猜你喜欢

转载自blog.csdn.net/yxw0609131056/article/details/79784490
今日推荐