【问题标题】:Why is this access denied by SELinux为什么 SELinux 拒绝此访问
【发布时间】:2017-08-08 10:50:15
【问题描述】:

我的音频 HAL 中有一个 unix 套接字守护程序,我需要从我的应用程序连接到它。

我收到 SELinux denied 日志如下:

08-08 10:38:01.939 2622-2622/com.xxx.xxx.xxx W/ksetsdk.xxx: type=1400 audit(0.0:511): avc: denied { connectto } for path=0023xxx scontext=u:r:system_app:s0 tcontext=u:r:audioserver:s0 tclass=unix_stream_socket permissive=0

即使我的应用使用平台密钥签名、安装在 system.img 中并作为系统运行,也会打印此内容:

root@hikey:/ # ps | grep xxx                                                                                                                                                                   
system    2619  1893  1561788 86956 SyS_epoll_ 0000000000 S com.xxx.xxx.xxx
root@hikey:/ # ps -Z | grep xxx                                                                                                                                                                
u:r:system_app:s0              system    2619  1893  1561788 86736 SyS_epoll_ 0000000000 S com.xxx.xxx.xxx
root@hikey:/ # 

我添加了 SEPolicy 如下:

auditallow system_app audioserver:unix_stream_socket { ioctl read getattr write setattr lock append bind connect getopt setopt shutdown connectto };

谁能指导我我错过了什么? AOSP SEPolicy 中是否有任何与此相矛盾的规则?如何让它工作?

【问题讨论】:

    标签: android android-source selinux


    【解决方案1】:

    在我构建 aosp 和更改 SEPolicy 规则时一定存在一些同步问题。

    我做了更详尽的测试,发现:

    (1) 当app通过platform key签名,并在manifest中请求system uid时,它作为system_app运行,遵循以下规则:

    auditallow system_app audioserver:unix_stream_socket { connectto };
    

    (2) 当应用通过平台密钥签名,但未在清单中请求系统 uid 时,它作为 platform_app 运行,但遵循规则不起作用

    auditallow platform_app audioserver:unix_stream_socket { connectto };
    

    (3) 如果 App 没有通过平台密钥签名,它作为 priv_app 运行,遵循规则不起作用

    auditallow priv_app audioserver:unix_stream_socket { connectto };
    

    我一定是在测试 AOSP 时弄混了什么规则。

    对我来说,为什么 priv_app 或 platform_app 不起作用,但 system_app 会遵循类似的规则,这对我来说仍然是个谜。

    【讨论】:

      猜你喜欢
      • 2012-02-07
      • 1970-01-01
      • 1970-01-01
      • 2012-05-05
      • 1970-01-01
      • 2023-03-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多