【问题标题】:AndroidP-SELinux Permission Denied for a new created service新创建的服务的 AndroidP-SELinux 权限被拒绝
【发布时间】:2021-01-05 03:01:51
【问题描述】:

当我添加一个新服务时,发现错误如下:

SELinux : avc:  denied  { add } for service=xxxManagerService pid=3798 uid=1000 scontext=u:r:system_server:s0 tcontext=u:object_r:default_android_service:s0 tclass=service_manager permissive=0

然后我在system_server.te 中添加允许:

allow system_server default_android_service:service_manager { add };

但是发生了构建错误:

libsepol.report_failure: neverallow on line 517 of system/sepolicy/public/domain.te (or line 10355 of policy.conf) violated by allow system_server default_android_service:service_manager { add };
libsepol.check_assertions: 1 neverallow failures occurred
Error while expanding policy
out/host/linux-x86/bin/checkpolicy:  loading policy configuration from out/target/product/sti6030d111/obj/ETC/sepolicy_neverallows_intermediates/policy.conf
[ 11% 22/200] target thumb C++: libpqcontrol <= vendor/amlogic/common/frameworks/services/systemcontrol/PQ/SSMAction.cpp

我应该怎么做才能通过 cts。

【问题讨论】:

    标签: android linux permissions selinux cts


    【解决方案1】:

    Android 附带一长串neverallow 规则,可确保您不会授予破坏设备安全性的权限。幸运的是,这些neverallow 规则在代码中都有详细记录。如果您在system/sepolicy/public/domain.te 中查找第 517 行,您会发现:

    不允许为默认服务标签添加 service_manager。 相反,域应该使用更具体的类型,例如 system_app_service 而不是泛型类型。 新的 service_types 在 {,hw,vnd}service.te 和新的映射中定义 从服务名称到 service_type 在 {,hw,vnd}service_contexts 中定义。

    您可能使用audit2allow 来创建规则。起初这似乎是一个简单的解决方案,但它几乎总是会导致规则集难以阅读。最后,除了了解 Android 中的 SELinux 基础知识之外别无他法。

    更多信息请参见here

    我无法举例说明现在该怎么做,因为您需要做的事情取决于您要添加的服务类型。

    【讨论】:

      猜你喜欢
      • 2016-03-31
      • 2016-03-05
      • 1970-01-01
      • 2016-01-04
      • 1970-01-01
      • 2022-06-24
      • 1970-01-01
      • 1970-01-01
      • 2022-01-23
      相关资源
      最近更新 更多