供供应商访问设备绑定器的 SePolicy

SePolicy for Vendor to access device binder

我面临的问题是我有一个正在访问 hwservice 管理器的供应商域,当我为用户构建编译时,我得到以下拒绝。

11-11 11:13:28.126  5228  5228 W vps     : type=1400 audit(0.0:248): avc: denied { read write } for name="binder" dev="tmpfs" ino=11419 scontext=u:r:vpsd:s0 tcontext=u:object_r:binder_device:s0 tclass=chr_file permissive=0

在 运行 audit2allow 工具之后,我得到了添加如下策略的建议。

allow vpsd binder_device:chr_file { ioctl open read write };

但根据高音架构,它是不允许的,构建失败。

错误如下:

Compilation error.
neverallow check failed at out/target/product/titan_r1_base/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil:2633
  (neverallow base_typeattr_38_26_0 binder_device_26_0 (chr_file (ioctl read write getattr lock append open)))
    <root>
    allow at out/target/product/titan_r1_base/obj/ETC/nonplat_sepolicy.cil_intermediates/nonplat_sepolicy.cil:5998
      (allow vpsd binder_device_26_0 (chr_file (read write)))

有人可以告诉我要为以上内容添加什么政策吗?

我试过了

allow vpsd hwbinder_device:chr_file { ioctl open read write };

allow vpsd vndbinder_device:chr_file { ioctl open read write };

求推荐。

新的高音架构旨在解耦供应商组件对框架的依赖。反过来,这将允许在不让供应商参与该过程的情况下升级框架(参见 Treble)。

为实现这一点,供应商组件对框架绑定器的访问受到限制,并且只能使用 vndbinder(供应商绑定器)与其他供应商组件进行交互。本质上,供应商组件不应直接与框架交互。

在高音版本 (8.0 +) 上,SE-Policy 通过定义 'coredomain' neverallow 规则来强制执行此概念。基本上,大多数内部框架组件和流程都与 coredomain 属性相关联,而新的供应商定义的组件与 coredomain 属性无关。 这意味着,当您在供应商中定义新类型时 SE-policy,该类型将不是核心域,并且将受到 neverallow 规则的限制。

Framework processes described in this section correspond to coredomain in sepolicies while vendor processes correspond to non-coredomain. For example, /dev/binder can be accessed only in coredomain and /dev/vndbinder can be accessed only in non-coredomain.

(来源:AOSP official documentation)。

具体在public domain.te文件下可以看到neverallow规则,定义只有coredomain + appdomain可以read/write binder_device:

#On full TREBLE devices, only core components and apps can use Binder and servicemanager. Non-core domain apps need this because Android framework offers many of its services to apps as Binder services.

full_treble_only(` neverallow { domain -coredomain -appdomain -binder_in_vendor_violators # TODO(b/35870313): Remove once all violations are gone } binder_device:chr_file rw_file_perms;