【问题标题】:Android Read file denied by SELinuxSELinux 拒绝 Android 读取文件
【发布时间】:2016-08-10 01:14:59
【问题描述】:

我最近尝试在 Android 中读取文件 /system/bin/debuggerd。我可以安装应用程序或使用 adb 命令但出现此错误:

很遗憾我被 SELinux 拒绝了

 [105336.331813] type=1400 audit(8732769.717:226): avc: denied { read } for pid=17773 comm="ServiceHandlerB" name="debuggerd" dev="dm-0" ino=279 scontext
 =u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:debuggerd_exec:s0 tclass=file permissive=0

我不能按规则root这个设备,所以可以读取这个文件吗? 这困扰了我一整天,谢谢帮助。

【问题讨论】:

    标签: android file selinux


    【解决方案1】:

    如果你不能“root”设备,那就不行。

    详情如下。 debuggerd_exec 文件声明为:

    type debuggerd_exec, exec_type, file_type;
    

    这意味着尝试读取文件的进程需要对 debuggerd_exec 类型或属性 exec_type 或 file_type 的读取权限。

    使用本回复时AOSP master的当前tip和午餐目标aosp_x86_64-eng,我们可以通过以下sesearch命令查看哪些“源域”实际上可以读取该文件:

    $ sesearch -A -t debuggerd_exec -c file -p read $OUT/root/sepolicy 
    allow debuggerd debuggerd_exec:file { read open getattr entrypoint execute };
    allow debuggerd exec_type:file { read lock ioctl open getattr };
    allow init debuggerd_exec:file { read getattr open execute };
    allow perfprofd exec_type:file { read lock ioctl open getattr };
    

    如果您注意到源域(允许之后的第一件事),它们都不是 shell 或 untrusted_app。在非 root 用户构建中,如果没有利用漏洞,则只能在 untrusted_app 或 shell 域中运行代码(这并不完全正确,但细节并不重要)。

    此外,即使 untrusted_app 确实具有访问权限,您也需要注意,即使 sesearch 显示您具有访问权限,MLS 有时也会阻止访问。 SE Linux on Android 使用类型强制(允许规则)和 MLS(mls_constrain 规则)来提供隔离和沙盒强化。

    【讨论】:

      猜你喜欢
      • 2016-05-16
      • 1970-01-01
      • 1970-01-01
      • 2021-10-05
      • 1970-01-01
      • 2021-11-25
      • 2021-12-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多