当前位置: 首页 > 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.gsyq.cn/news/114809.html

相关文章:

  • 第35章 Shell 结合curl实现接口测试:GET/POST请求+响应解析
  • 智慧水务|供排水解决方案
  • 2025年质量好的金蝶印刷ERP行业口碑榜 - 行业平台推荐
  • 2025年终总结:国产洗板机知名品牌厂家推荐,附北京普天选购建议 - 品牌推荐大师
  • 2025年惠州审计公司权威推荐榜单:专业代账/公司注销/税务优化源头公司精选 - 品牌推荐官
  • 【time-rs】解释://! Error that occurred at some stage of parsing(error/parse.rs)
  • 清醒的堕落
  • 使用 Google Antigravity 在大地上码代码码
  • EmotiVoice语音合成在博物馆导览系统中的智能化升级
  • Nginx | HTTP 反向代理:与上游服务端建立连接处理实践
  • 告别PPT焦虑!百考通AI智能助手,一键生成专业答辩与开题PPT,让您的汇报闪耀全场
  • 基于深度学习YOLOV8道路裂缝检测系统 yolov8如何训练道路裂缝检测数据集
  • 开题报告PPT智能生成:从混沌到清晰的结构化展示
  • 高精度、低延迟、轻量化 YOLOV11创新点 骨干网络(backbone)改进 2、识别头改进 3、卷积块(Conv)改进 4、轻量化模型 5、移动端设计 6、多头注意力机制 7、空间和通道协同注意力
  • 告别繁琐问卷设计!百考通AI智能助手,5分钟生成专业调研问卷
  • 学术PPT颜值革命:百考通AI模板库与设计秘籍,告别“理工风审美”
  • Deepseek是被降智了吗?
  • 2025年年终西安管道疏通推荐:专业排行解析与多维度对比评测 - 品牌推荐
  • 把一维数组硬当成二维用:一次讲透 C 语言“指向数组的指针”
  • 神经紧张素受体SORT1
  • 【云计算】【Kubernetes】 ⑥ K8S Pod优雅下线全解析:从preStop到Eureka下线实战
  • 百考通AI:你的智能数据分析专家,从数据到洞察,一键生成专业报告
  • 血浆多组学网络如何揭示急性早幼粒细胞白血病的病理机制?
  • EmotiVoice本地化部署优势:数据安全与响应效率兼得
  • 小鼠分型试剂盒:如何通过高维流式技术实现免疫系统的全景解析?
  • 硫辛酸酯标记聚乙二醇单甲醚:mPEG-LA 的核心应用场景
  • 【Java毕设全套源码+文档】基于springboot的数据库课程在线教学系统设计与实现(丰富项目+远程调试+讲解+定制)
  • 深度测评汉唐数字传媒新媒体运营有实力吗、短视频运营能力及专业 - myqiye
  • 2025年年终贵阳管道疏通推荐:专业排行解析与多维度服务对比指南 - 品牌推荐
  • 探寻吉田美学化妆培训:靠谱、高性价比之选 - 工业推荐榜