Android11 SELinux:avc:denied { read } for name=“cache“ dev=“dm-4“ ino=16 scontext=u:r:system_app等报错

本文介绍了如何分析和解决Android系统中由于SELinux策略导致的AVC denied错误,通过在特定的.te文件中添加权限允许规则,确保system_app和其他进程对特定文件的读取和设置属性权限。遵循错误日志,定位受影响的文件类型和上下文,然后在设备策略文件中进行修正。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

(1) avc: denied { read } for name="cache" dev="dm-4" ino=16 scontext=u:r:system_app:s0 tcontext=u:object_r:cache_file:s0 tclass=lnk_file permissive=0

分析过程:

缺少什么权限:      {  read  }权限,

谁缺少权限:        scontext=u:r:system_app:s0

对哪个文件缺少权限:tcontext=u:object_r:cache_file:s0

什么类型的文件:    tclass=lnk_file

permissive=0  : 权限拒绝

完整的意思: system_app进程对cache_file类型的lnk_file缺少read权限。

解决的方法:

缺什么权限补什么,一步一步补到没有avc denied为止。

解决权限问题需要修改的权限文件如下位置,以.te结尾

device/mediatek/sepolicy/bsp/non_plat/system_app.te

device/mediatek/sepolicy/basic/non_plat/system_app.te

device/mediatek/sepolicy/basic/plat_private/system_app.te

device/mediatek/sepolicy/bsp/non_plat/system_app.te

device/mediatek/sepolicy/bsp/plat_private/system_app.te

在以上的路径文件中,加入以下代码

allow system_app cache_file:lnk_file read;
(2)avc: denied { read } for name="cache" dev="dm-4" ino=16 scontext=u:r:uncrypt:s0 tcontext=u:object_r:cache_file:s0 tclass=lnk_file permissive=0

解决思路同(1): 只是在找到的不同路径文件中,加入以下代码

allow uncrypt cache_file:lnk_file read;
(3)avc: denied { setattr } for name="uncrypt_file" dev="dm-9" ino=6587 scontext=u:r:system_app:s0 tcontext=u:object_r:cache_recovery_file:s0 tclass=file permissive=0

解决思路同(1): 只是在找到的不同路径文件中,加入以下代码

allow system_app cache_recovery_file:file setattr;

能在device中找到的.te文件尽量在其中添加selinux权限,而不是改变system下的selinux权限

感谢大佬的博文指导:https://blog.csdn.net/tung214/article/details/72734086

https://www.freesion.com/article/6573116485/

SELinux : avc: denied { find } for interface=vendor.xiaomi.hw.touchfeature::ITouchFeature sid=u:r:system_server:s0 pid=1578 scontext=u:r:system_server:s0 tcontext=u:object_r:default_android_hwservice:s0 tclass=hwservice_manager permissive=0 SELinux : avc: denied { find } for interface=vendor.xiaomi.hardware.cld::ICld sid=u:r:system_server:s0 pid=1578 scontext=u:r:system_server:s0 tcontext=u:object_r:hal_health_storage_hwservice:s0 tclass=hwservice_manager permissive=0 SELinux : avc: denied { find } for interface=vendor.qti.sla.service::ISlaService sid=u:r:system_server:s0 pid=1578 scontext=u:r:system_server:s0 tcontext=u:object_r:default_android_hwservice:s0 tclass=hwservice_manager permissive=0 SELinux : avc: denied { find } for interface=vendor.xiaomi.hidl.miwill::IMiwillService sid=u:r:system_server:s0 pid=1578 scontext=u:r:system_server:s0 tcontext=u:object_r:default_android_hwservice:s0 tclass=hwservice_manager permissive=0 SELinux : avc: denied { find } for interface=vendor.qti.sla.service::ISlaService sid=u:r:system_server:s0 pid=1578 scontext=u:r:system_server:s0 tcontext=u:object_r:default_android_hwservice:s0 tclass=hwservice_manager permissive=0 SELinux : avc: denied { find } for interface=vendor.xiaomi.hidl.minet::IMiNetService sid=u:r:system_server:s0 pid=1578 scontext=u:r:system_server:s0 tcontext=u:object_r:default_android_hwservice:s0 tclass=hwservice_manager permissive=0 SELinux : avc: denied { find } for interface=vendor.xiaomi.hidl.minet::IMiNetService sid=u:r:system_server:s0 pid=1578 scontext=u:r:system_server:s0 tcontext=u:object_r:default_android_hwservice:s0 tclass=hwservice_manager permissive=0 SELinux : avc: denied { find } for interface=vendor.xiaomi.hw.touchfeature::ITouchFeature sid=u:r:system_app:s0 pid=3872 scontext=u:r:system_app:s0 tcontext=u:object_r:default_android_hwservice:s0 tclass=hwservice_manager permissive=0 SELinux : avc: denied { find } for interface=vendor.xiaomi.hardware.fbo::IFbo sid=u:r:system_server:s0 pid=1578 scontext=u:r:system_server:s0 tcontext=u:object_r:default_android_hwservice:s0 tclass=hwservice_manager permissive=0 SELinux : avc: denied { find } for interface=vendor.xiaomi.hardware.fbo::IFbo sid=u:r:system_server:s0 pid=1578 scontext=u:r:system_server:s0 tcontext=u:object_r:default_android_hwservice:s0 tclass=hwservice_manager permissive=0 SELinux : avc: denied { find } for interface=vendor.xiaomi.hardware.campostproc::IMiPostProcService sid=u:r:platform_app:s0:c512,c768 pid=9054 scontext=u:r:platform_app:s0:c512,c768 tcontext=u:object_r:default_android_hwservice:s0 tclass=hwservice_manager permissive=0 SELinux : avc: denied { find } for interface=vendor.xiaomi.hw.touchfeature::ITouchFeature sid=u:r:system_app:s0 pid=10143 scontext=u:r:system_app:s0 tcontext=u:object_r:default_android_hwservice:s0 tclass=hwservice_manager permissive=0 SELinux : avc: denied { find } for interface=vendor.xiaomi.hw.touchfeature::ITouchFeature sid=u:r:system_app:s0 pid=10143 scontext=u:r:system_app:s0 tcontext=u:object_r:default_android_hwservice:s0 tclass=hwservice_manager permissive=0 SELinux : avc: denied { find } for interface=vendor.xiaomi.hw.touchfeature::ITouchFeature sid=u:r:system_app:s0 pid=11940 scontext=u:r:system_app:s0 tcontext=u:object_r:default_android_hwservice:s0 tclass=hwservice_manager permissive=0 SELinux : avc: denied { find } for interface=vendor.xiaomi.hardware.wireless::IWirelessSwitch sid=u:r:system_app:s0 pid=12014 scontext=u:r:system_app:s0 tcontext=u:object_r:default_android_hwservice:s0 tclass=hwservice_manager permissive=0 SELinux : avc: denied { find } for interface=vendor.xiaomi.hardware.fbo::IFbo sid=u:r:system_server:s0 pid=1578 scontext=u:r:system_server:s0 tcontext=u:object_r:default_android_hwservice:s0 tclass=hwservice_manager permissive=0
最新发布
07-24
[ 62.097451] type=1400 audit(1686032696.903:62): avc: denied { map } for comm="network.sh" path="/system/bin/sh" dev="dm-7" ino=720 scontext=u:r:network_sh:s0 tcontext=u:object_r:shell_exec:s0 tclass=file permissive=1 [ 62.097570] type=1400 audit(1686032696.903:62): avc: denied { read } for comm="network.sh" path="/system/bin/sh" dev="dm-7" ino=720 scontext=u:r:network_sh:s0 tcontext=u:object_r:shell_exec:s0 tclass=file permissive=1 [ 62.097709] type=1400 audit(1686032696.903:62): avc: denied { execute } for comm="network.sh" path="/system/bin/sh" dev="dm-7" ino=720 scontext=u:r:network_sh:s0 tcontext=u:object_r:shell_exec:s0 tclass=file permissive=1 [ 62.113304] type=1400 audit(1686032696.935:63): avc: denied { getattr } for comm="network.sh" path="/system/bin/sh" dev="dm-7" ino=720 scontext=u:r:network_sh:s0 tcontext=u:object_r:shell_exec:s0 tclass=file permissive=1 [ 62.143732] type=1400 audit(1686032696.971:64): avc: denied { read } for comm="network.sh" name="ifconfig" dev="dm-7" ino=561 scontext=u:r:network_sh:s0 tcontext=u:object_r:init-ifconfig_exec:s0 tclass=lnk_file permissive=1 [ 62.150395] type=1400 audit(1686032696.971:64): avc: denied { getattr } for comm="network.sh" path="/system/bin/toybox" dev="dm-7" ino=766 scontext=u:r:network_sh:s0 tcontext=u:object_r:toolbox_exec:s0 tclass=file permissive=1 [ 62.150484] type=1400 audit(1686032696.979:65): avc: denied { execute } for comm="network.sh" name="toybox" dev="dm-7" ino=766 scontext=u:r:network_sh:s0 tcontext=u:object_r:toolbox_exec:s0 tclass=file permissive=1 [ 62.150537] type=1400 audit(1686032696.979:66): avc: denied { read open } for comm="network.sh" path="/system/bin/toybox" dev="dm-7" ino=766 scontext=u:r:network_sh:s0 tcontext=u:object_r:toolbox_exec:s0 tclass=file permissive=1 [ 62.150676] type=1400 audit(1686032696.979:66): avc: denied { execute_no_trans } for comm="network.sh" path="/system/bin/toybox" dev="dm-7" ino=766 scontext=u:r:network_sh:s0 tcontext=u:object_r:toolbox_exec:s0 tclass=file permissive=1 [ 62.151933] type=1400 audit(1686032696.979:66): avc: denied { map } for comm="ifconfig" path="/system/bin/toybox" dev="dm-7" ino=766 scontext=u:r:network_sh:s0 tcontext=u:object_r:toolbox_exec:s0 tclass=file permissive=1 改写avc规则
06-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

奔跑滴小羊

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值