Android Selinux权限问题
1.1:log提示:
type=1400 audit(1262304982.420:57113): avc: denied { sys_ptrace } for pid=1 comm=“init” capability=19 scontext=u:r:init:s0 tcontext=u:r:init:s0 tclass=capability permissive=0
1.2:log格式:
avc: denied { 操作权限 } for pid=1 comm=“进程名” scontext=u:r:源类型:s0 tcontext=u:r:目标类型:s0 tclass=访问类别 permissive=0
2:修改方法
2.1
在 /android/system/sepolicy/init.te 文件中添加
allow init init:capability { sys_ptrace };
备注:这个例子中,由于源类型和目标类型都是init,所以也可以用下面的方法:
allow init self:capability { sys_ptrace };
标准格式:allow 源类型 目标类型:访问类别 { 操作权限 };
2.2
也可以通过adb临时修改
root/# setenforce 0 -->关闭selinux
root/# serenforce 1 -->打开selinux
root/# getenforce -->获取当前selinux权限状态
|— Enforcing -->打开状态
|— Permissive -->关闭状态
2.3 从kernel中彻底关闭
android/kernel/arch/arm64/configs/XXXdefconfig文件(找相应config文件)
去掉CONFIG_SECURITY_SELINUX=y 的配置项
3添加权限后 neverallow冲突
libsepol.report_failure: neverallow on line 162 of system/sepolicy/domain.te (or line 8961 of policy.conf) violated by allow init init:capability { sys_ptrace };
去system/sepolicy/domain.te 文件 的 162行
neverallow {
domain
-debuggerd
-vold
-dumpstate
-system_server
userdebug_or_eng(`-perfprofd’)
} self:capability sys_ptrace;
在中间增加 -init
以下是网上的修改方法
3.1 编译报错:
libsepol.check_assertion_helper: neverallow on line xxx ofexternal/sepolicy/domain.te ……
3.2 原因:
新添加的sepolicy项目违反了domain.te 中规定的的总策略原则。所以该条权限策略不能添加,如果强行添加的话有CTS测试失败的风险。
3.3 解决方法:
1.从运行log中找到要访问的目标名称,一般是name字段后的名称
avc: denied { read write } for pid=303 comm=“mediaserver” name="tfa9890"dev=“tmpfs” ino=3880 scontext=u:r:mediaserver:s0tcontext=u:object_r:device:s0tclass=chr_file permissive=0
2.找到相应的*_contexts文件。
一般有file_contexts, genfs_contexts, property_contexts, service_contexts 等文件
3.在contexts文件中指定要访问的目标为一个“源类型 ”有权限访问的“目标类型”
如:在file_contexts中添加: /dev/tfa9890 u:object_r:audio_device:s0
3.4 举例
添加权限:
在mediaserver.te中添加allow mediaserver device:chr_file { read write open};
编译报错:
libsepol.check_assertion_helper: neverallow on line 258 ofexternal/sepolicy/domain.te (or line 5252 of policy.conf) violated byallow mediaserver device:chr_file { read write open};
违反了domain.te 258的:
neverallow {domain –unconfineddomain –ueventd } device:chr_file { open read write}
运行Log:
avc: denied { read write } for pid=303 comm="mediaserver"name=“tfa9890” dev=“tmpfs” ino=3880 scontext=u:r:mediaserver:s0 tcontext=u:object_r:device:s0tclass=chr_file permissive=0
修改步骤:
1.目标名称是: tfa9890, 其在系统中的路径是: /dev/tfa9890, 是audio相关的设备文件
2.源类型是mediaserver, 在mediaserver.te 文件中发现其具有 audio_device 目标类型的权限
3.所以在file_contexts 中添加 “/dev/tfa9890 u:object_r:audio_device:s0” 可以解决问题
特别的问题:
1、
te文件已经有了allow权限,仍然一直出现avc的权限问题
解决方法:
2、
Binder:3775_2: type=1400 audit(0.0:4): avc: denied { write } for name="/" dev=“mmcblk1p1” ino=5 scontext=u:r:platform_app:s0:c512,c768 tcontext=u:object_r:unlabeled:s0 tclass=dir permissive=0
已经在system/sepolicy/platform_app.te 中添加了下面语句,仍然会一直出现avc的权限问题
allow platform_app unlabeled:dir { write }
(不知道是不是和c512,c768有关)
解决:
在system/sepolicy/platform_app.te添加: mlstrustedsubject
type platform_app, domain, domain_deprecated, mlstrustedsubject;
Android Selinux权限问题相关推荐
- Android selinux权限修改
原文地址:https://skytoby.github.io/2019/selinux%E4%BF%AE%E6%94%B9/ 方法一:adb修改SELinux Enforcing(已打开) Permi ...
- 详解Android Selinux 权限及问题
由于现做的是MTK平台,源码路径基于MTK, 不过高通大同小异 说明 Android 5.0以后完全引入了 SEAndroid/SELinux 安全机制,这样即使拥有 root 权限或 chmod 7 ...
- Android Selinux 权限配置
1.SElinux三种权限: enforcing:强制模式.代表SELinux运行中,且已经正确的开放限制 domain/type. permissive:宽容模式.代表SELinux运行中,不过金会 ...
- Android SELinux开发入门指南之如何增加Native Binder Service权限
Android SELinux开发入门指南之如何增加Native Binder Service权限 Android SELinux开发多场景实战指南目录: Android SELinux开发入门指 ...
- Android SELinux开发入门指南之正确姿势解决访问data目录权限问题
Android SELinux开发入门指南之正确姿势解决访问data目录权限问题 Android SELinux开发多场景实战指南目录: Android SELinux开发入门指南之SELinux ...
- Android SELinux开发入门指南之如何增加Java Binder Service权限
Android SELinux开发入门指南之如何增加Java Binder Service权限 Android SELinux开发多场景实战指南目录: Android SELinux开发入门指南之 ...
- Android中SeLinux权限 .te文件编写
在android中添加一个LocalSocket通信,权限部分折腾了好几天,终于搞定了. 首先在root权限下使用setenforce 0命令放开selinux权限,看看需要的操作是否能成功.如果可以 ...
- [Android]开机自启动脚本和selinux权限配置
概述 在前段时间的工作中,需要开发一个开机自动启动的脚本,现把开发过程记录一下 主要框架 编写一个可以开机自动启动的脚本,方法就是通过rc文件,在boot_complete=1时,去启动这个服务,那么 ...
- Android 使用 audit2allow 工具添加SELinux权限
开发应用报错,提示 avc: denied { write } for comm="com.test" name="/" dev="dm-5" ...
最新文章
- Mac pro 上安装 robotframework 时的一个版本问题
- C/C++:Windows cmd 指令
- 全新ARM base PocketPC 2003 Emulator Beta 已登場。
- 【活动报名】2021蚂蚁链开发者大会
- Linux下 -bash: php: command not found 命令找不到
- WCF Data Services服务端处理汇总
- oracle中subject是什么意思,subject是什么意思_subject的翻译_音标_读音_用法_例句_爱词霸在线词典...
- ExactScan pro for mac(扫描仪整合工具)
- 带通滤波器的matlab程序设计
- 数据处理与分析|涵盖七大分析方法
- 工业相机SDK二次开发
- 自行设计开源的pdf转word软件(python开发设计)
- 微信小程序│ 游戏开发 │连连看游戏
- xtu 1403 菱形 思路清晰
- 内网渗透篇-信息收集
- ps图层模式详解带计算公式
- matlab读取wav文件出错,MATLAB读取wav文件
- 初识Continuation
- 快递100企业版接口(API)gitee
- JAVA批量获取归属地所有手机号