当前位置: 首页 > news >正文

android selinux报avc denied权限和编译报neverallow解决方案

avc: denied { read } for name=“present” dev=“sysfs” ino=42693 scontext=u:r:hal_health_default:s0 tcontext=u:object_r:sysfs:s0 tclass=file permissive=1
denied {xxx}: 表示缺少什么权限
scontext:表示谁缺少权限
tcontext:表示对那些文件缺少权限:
tclass:表示什么文件类型缺少权限
修改公式如下:
通常需要在${scontext}.te添加 allow scontext tcontext:tclass denied
带入内容:修改hal_health_default.te
allow hal_health_default sysfs:fie { read };
allow hal_health_default sysfs:fie { open};

RK平台te文件一般在device/rockchip/common/sepolicy/下 类似上面的修改即可

如果编译时报错 提示

libsepol.report_failure: neverallow on line 444 of system/sepolicy/public/domain.te (or line 12990 of policy.conf) violated by allow tee device:chr_file { read write };
libsepol.check_assertions: 1 neverallow failures occurred
Error while expanding policy

报错原因也比较直接,就是domain域中指明的规则,我们先看下为什么会报错吧
直接打开编译报错中那个domain.te,路径:system/sepolicy/public/domain.te,找到和我们添加的部分,搜索“device:chr_file”,可以找到如下内容了,看一下就明白了,不允许我们这样修改了。

# Don't allow raw read/write/open access to generic devices.
# Rather force a relabel to a more specific type.
neverallow domain device:chr_file { open read write };

以下是实例,我这边提示system_app权限异常

avc: denied { read } for name="u:object_r:serialno_prop:s0" dev="tmpfs" ino=12228 scontext=u:r:system_app:s0 tcontext=u:object_r:serialno_prop:s0 tclass=file permissive=1

在device/rockchip/common/sepolicy/system_app.te下修改

allow system_app serialno_prop:file { open read getattr };

提示neverallow错误 找到对应的domain.te

system/sepolicy/public/domain.te

# a few whitelisted domains.
neverallow {domain-adbd-dumpstate-hal_drm-hal_cas-init-mediadrmserver-recovery-shell-system_server
} serialno_prop:file r_file_perms;

查看到serialno_prop:file,其实直接将domain修改为-domain即可

neverallow {-domain-adbd-dumpstate-hal_drm-hal_cas-init-mediadrmserver-recovery-shell-system_server
} serialno_prop:file r_file_perms;


http://www.mrgr.cn/news/12982.html

相关文章:

  • 论文阅读笔记:RepViT: Revisiting Mobile CNN From Vit Perspective
  • Linux C创建进程及父子进程虚拟地址空间(附源码)
  • 通过python解决原神解密
  • Stable Diffusion的微调方法原理总结
  • cordova手动更新
  • 前端实现模块懒加载
  • 有哪些内部知识库类似钉钉,满足企业多样化需求?
  • Oracle 11g数据库与某个表的最新一笔记录进行关联
  • go国内源设置
  • 16岁激活交学费银行卡需要本人实名电话卡,线下营业厅不给办,怎么办?
  • 自动化01:认识接线端子
  • docker0: iptables: No chain/target/match by that name问题解决
  • git如何将多个提交合并为一个提交
  • Linux网络
  • Maven基本使用
  • 本地化云桌面系统环境VMware horizon搭建
  • Zotero打开后所有文献及笔记都消失了
  • Spring Boot使用拦截器(Interceptor)
  • 黑神话悟空无法登录服务器怎么办
  • 数据库系统 第28节 数据库迁移 案例分析