微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 手机设计讨论 > MTK手机平台交流 > Android L APP如何获取proc file system中节点的写权限

Android L APP如何获取proc file system中节点的写权限

时间:10-02 整理:3721RD 点击:
[Description]

android L APP 如何获取proc file system 中节点的写权限

[Keyword]

L SElinux proc write

[Android Version]

Version >= android 5.0

[Solution]

Google 默认禁止app , 包括system app, radio app 等直接写/proc 下面的文件, 认为这个是有安
全风险的。如果直接放开SELinux 权限, 会导致CTS 无法通过.
通常遇到此类情况,你有两种做法:
(1). 通过system server service 或者 init 启动的service 读写, 然后app 通过binder/socket
等方式连接APP 访问. 此类安全可靠, 并且可以在service 中做相关的安全审查, 推崇这种方法.
(2). 修改对应节点的SELinux Security Label, 为特定的APP, 如system app, radio, bluetooth
等内置APP开启权限, 但严禁为untrsted app 开启权限. 具体的做法下面以 radio app 控制
/proc/gt9xx_wakeup 来说明.
* 在device/mediatek/common/sepolicy/file.te 定义gt9xx_wakeup SELinux type
type proc_gt9xx_wakeup, fs_type;
* 在device/mediatek/common/sepolicy/genfs_contexts 绑定 gt9xx_wakeup 对应的label, 注意
对应的节点是实际节点,而不是链接.以及整个目录路径中也绝不能包含链接(无数同仁有犯这个错
误,特意提醒)
genfscon proc /gt9xx_wakeup ubject_r:proc_gt9xx_wakeup:s0
* 在device/mediatek/common/sepolicy/xxxxx.te 中申请权限. 比如假如是工模下面,一般是
radio app, radio.te
allow radio proc_gt9xx_wakeup:file rw_file_perms;
*. 为其它的process 申请相关的权限,如system_server, 在
device/mediatek/common/sepolicy/system_server.te
allow system_server proc_gt9xx_wakeup:file rw_file_perms;
原则上我们都推崇使用第一种方式处理.

感谢小编,谢谢分享!

:handshake

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top