我遇到麻烦了,我有一个应用程序需要访问由内核驱动程序创建的/ proc条目,并且遇到了selinux被拒绝的问题:

avc: denied { write } for pid=30200 comm="omg.flashlight" name="omg_flash_brightness" dev="proc" ino=4026534208 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:proc:s0 tclass=file permissive=0


我尝试解决此拒绝问题,但发现无法允许untrusted_app编写proc:file,因为会出现CTS问题。我尝试为omg.flashlight APP添加域。我使用ps -Z并发现以下APP

u:r:untrusted_app:s0:c512,c768 u0_a89    6669  382   com.omg.flashlight


我尝试添加以下设置以使其在seapp_contexts中成为selinux域:

user=app domain=omg_flashlight seinfo=platform name=com.omg.flashlight type=app_data_file


我新建了一个omg_flashlight.te:

type omg_flashlight,domain;
app_domain(omg_flashlight)


但是结果是一样的,APP仍然是untrusted_app。

有人知道吗?
我发现有c512,c768。有人知道这是什么吗?

谢谢!

最佳答案

首先,您需要修复seapp_context文件中的行:

user=_app seinfo=omg_flashlight domain=platform_app name=com.omg.flashlight type=app_data_file


user=_app始终以下划线开头。

u:r:untrusted_app:s0:c512,c768运行的进程具有特殊的特权,可以访问类别c512,c768中的文件。但是您需要访问没有多级类别u:object_r:proc:s0的文件类型,所以我认为这不是您的问题。

尝试使您的应用程序以platform_appsystem_app身份运行,具体取决于您的设备,并且您应该可以访问。

更新资料

您已经在seapp_context中混合了seinfodomain,请参见上文。如果platform_app不起作用,请尝试system_app
转到/system/etc/security/mac_permissions.xml并查找应用程序的seinfo,它应与seapp_contexts中定义的相同。

<signer signature="your_app_signature"><allow-all/><seinfo value="omg_flashlight"/></signer>


如果您的应用程序密钥也正确,那么它将现在在seapp_contexts定义的域中运行。

08-04 08:59