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

Android selinux 权限 修复 avc: denied


selinux
{
getenforce 串口命令查看权限

selinux=0 内核关闭 selinux
selinux=1 内核打开 selinux

android 系统 两种模式
androidboot.selinux=permissive 宽松
androidboot.selinux=enforcing 强制

getenforce
setenforce 0 命令,让 selinux 处于宽容模式

sn: getprop ro.serialno
mac: cat /sys/class/net/wlan0/address


相关文件
{
修改权限最好在device下客制化修改
device/xxx/xxx/sepolicy/

原始code的权限最好不要动
system/sepolicy/public/
system/sepolicy/prebuilts/api/xx/public/

}

设置文件 device/softwinner/eros-p1/BoardConfig.mk
BOARD_KERNEL_CMDLINE += selinux=1 androidboot.selinux=permissive androidboot.dtbo_idx=0,1,2
BOARD_KERNEL_CMDLINE += selinux=1 androidboot.selinux=enforcing androidboot.dtbo_idx=0,1,2

权限报错,类似提示
{
init: Unable to set property 'persist.standby.mode' to '1' from uid:1000 gid:1000 pid:7184: SELinux permission check failed
[ 2.047169] selinux: avc: denied { set } for scontext=u:r:vendor_init:s0 tcontext=u:object_r:default_prop:s0 tclass=property_service permissive=1
[ 2.064680] selinux: avc: denied { set } for scontext=u:r:vendor_init:s0 tcontext=u:object_r:config_prop:s0 tclass=property_service permissive=1
[ 2.081488] selinux: avc: denied { set } for scontext=u:r:vendor_init:s0 tcontext=u:object_r:exported2_default_prop:s0 tclass=property_service permissive=1
[ 153.759885] selinux: avc: denied { set } for property=persist.standby.mode pid=3928 uid=1000 gid=1000 scontext=u:r:system_app:s0 tcontext=u:object_r:default_prop:s0 tclass=property_service permissive=1
[ 178.937290] selinux: avc: denied { set } for property=settings.notifi.count pid=2183 uid=1000 gid=1000 scontext=u:r:system_server:s0 tcontext=u:object_r:default_prop:s0 tclass=property_service permissive=1
avc: denied { write } for name="light" dev="sysfs" ino=14600 scontext=u:r:system_server:s0 tcontext=u:object_r:sysfs_gpio:s0 tclass=file permissive=0
}

方法一 修改
vendor/aw/homlet/sepolicy/property_contexts
system/sepolicy/.../property_contexts
{
system_prop 对应的只能在 系统层app才能使用
ro.datamax.RomVersion u:object_r:system_prop:s0
persist.ota.server u:object_r:system_prop:s0
persist.standby.mode u:object_r:system_prop:s0
}


方法二
{
抓取相关log,提取权限名称。
dmesg|grep avc
获取所有的avc 权限问题
logcat|grep avc: > /sdcard/avc.log

linux工具 需要先 source build/envsetup.sh & lunch
audit2allow -i avc.log

源码中使用工具生成
{
#============= hal_wifi_default ==============
allow hal_wifi_default vendor_data_file:file getattr;

#============= init ==============
allow init settings_service:service_manager find;
allow init system_file:file execute_no_trans;

#============= system_app ==============
allow system_app system_data_file:file { write read create };
}
根据生成的条件修改 te文件

system/sepolicy/public/system_app.te
allow system_app system_data_file:dir { add_name write };
allow system_app system_data_file:file { create open write };

报错提示:
libsepol.report_failure: neverallow on line 458 of system/sepolicy/public/app.te (or line 8332 of policy.conf) violated by allow system_app system_data_file:dir { write };
libsepol.report_failure: neverallow on line 458 of system/sepolicy/public/app.te (or line 8332 of policy.conf) violated by allow system_app system_data_file:file { write create };
libsepol.check_assertions: 2 neverallow failures occurred

找到 app.te 中对应的 458 等行修改
{
原始:
neverallow appdomain system_data_file:dir_file_class_set
{ create write setattr relabelfrom relabelto append unlink link rename };

修改后 1
neverallow appdomain -system_app system_data_file:dir_file_class_set
{ create write setattr relabelfrom relabelto append unlink link rename };

修改后 2
neverallow appdomain system_data_file:dir_file_class_set
{ setattr relabelfrom relabelto append unlink link rename };
}

报错提示:
Files system/sepolicy/prebuilts/api/28.0/public/app.te and system/sepolicy/public/app.te differ
对比两个文件输入的字符,一个空格都要一致

编译测试
make selinux_policy
}
}

http://www.jsqmd.com/news/104003/

相关文章:

  • 第35章 Shell 结合curl实现接口测试:GET/POST请求+响应解析
  • 【Java毕设源码分享】基于springboot+vue的敦煌文化旅游管理系统的设计与实现(程序+文档+代码讲解+一条龙定制)
  • 智慧水务|供排水解决方案
  • 《60天AI学习计划启动 | Day 33: 前端 AI 状态管理 缓存(会话 / 历史 / 本地持久化)》
  • 系统设计:高并发企业级限流方案+原理
  • Webtop Docker 容器化部署指南:基于浏览器的Linux桌面环境
  • 【Java毕设源码分享】基于springboot+vue的宠物猫售卖管理系统设计与实现(程序+文档+代码讲解+一条龙定制)
  • Docker 开发与使用教程 - Ubuntu 24.04 完整指南
  • 天津市自建房设计公司哪家强?2025 最新评测排行榜 + 5 星企业推荐 - 苏木2025
  • 架构设计:Rocketmq - 消息0丢失企业级实践
  • 【2025市场分析】沸腾干燥机高精度实力厂家哪家好/行业领先企业定制推荐 - 品牌推荐大师
  • 【Java毕设源码分享】基于springboot+vue的少数民族音乐网站的设计与实现(程序+文档+代码讲解+一条龙定制)
  • 2025年质量好的金蝶印刷ERP行业口碑榜 - 行业平台推荐
  • watch 防抖设计
  • 2025年年终西安管道疏通推荐:热门服务商榜单及全方位对比解读 - 品牌推荐
  • 技术日报|AI工作流工具Sim二连冠日增1357星,Claude记忆插件强势回归第二
  • 2025年潮州专业新媒体运营公司排行榜,推荐专业诚信的新媒体 - 工业推荐榜
  • 2025年终总结:国产洗板机知名品牌厂家推荐,附北京普天选购建议 - 品牌推荐大师
  • 提升企业数据安全的文件外发系统有哪些特点与优势
  • 2025年惠州审计公司权威推荐榜单:专业代账/公司注销/税务优化源头公司精选 - 品牌推荐官
  • 2025 年 12 月活性炭厂家权威推荐榜:蜂窝/柱状/颗粒全系解析,废气净化与深度过滤的工业级优选方案 - 品牌企业推荐师(官方)
  • 面试官一句话把我问懵了:Java 都不快了,为什么公司还在用?
  • 告别播放难题!m3u8play.cn——专业M3U8流媒体播放神器来袭
  • 高质量财务分析报告:全流程指南与实操技巧
  • 2025年12月湖南环保家装板材,全屋定制家装板材,好看家装板材厂家测评:甲醛释放量达标品牌推荐 - 品牌鉴赏师
  • 钓鱼攻击低谷期的战术潜伏与防御前瞻
  • 【time-rs】解释://! Error that occurred at some stage of parsing(error/parse.rs)
  • 启天 M 系列 Smart Power On/Fast boot 置灰?2 步解锁修改权限!
  • 2025 年 12 月周转箱模具厂家权威推荐榜:折叠/物流/蔬菜/大型/注塑/PP/HDPE塑料周转箱模具,创新设计与耐用品质深度解析 - 品牌企业推荐师(官方)
  • 情感强度滑动调节功能上线!EmotiVoice更灵活