Android的Logcat在tmpfs上充斥着selinux avc拒绝,由kworker / kernel输入1400

如何解决Android的Logcat在tmpfs上充斥着selinux avc拒绝,由kworker / kernel输入1400

我正在用这些警告向我的Android Logcat发送垃圾邮件。(以magisk为根)

10-15 22:02:29.039 12944 12944 W kworker/0:4: type=1400 audit(0.0:87190): avc: denied { read write } for name="sde73" dev="tmpfs" ino=28978 scontext=u:r:kernel:s0 tcontext=u:object_r:oem_device:s0 tclass=blk_file permissive=0

我正在调查以下文档,以查看如何解决此问题,但无法解决。

https://source.android.com/security/selinux/device-policy

https://source.android.com/security/selinux/validate

https://source.android.com/security/selinux/concepts

https://source.android.com/security/selinux/implement

https://gist.github.com/msfjarvis/ec52b48eb2df1688b7cbe32bcd39ee5f

https://android.stackexchange.com/questions/207484/how-to-fix-selinux-avc-denied-errors-when-launching-dnscrypt-as-init-d-script

https://source.android.com/security/selinux/customize#android-o

https://android.stackexchange.com/questions/218911/how-to-add-selinux-policy-on-a-user-debug-rom-that-has-split-policy-scheme

https://android.stackexchange.com/questions/214839/how-to-run-an-android-init-service-with-superuser-selinux-context

https://topjohnwu.github.io/Magisk/tools.html#magiskpolicy

https://topjohnwu.github.io/Magisk/details.html#magisk-booting-process

https://topjohnwu.github.io/Magisk/guides.html#boot-scripts

我看着/dev,但没有相似之处。

android# ls -l /dev/ | grep sd
#returns nothing

inode解析为以下文件:

find /sys -xdev -inum 28978
/sys/firmware/devicetree/base/__symbols__/sb_7_tx

但是,在下次重新启动时,它会解析为其他文件,但是错误始终与单个inode有关。

我想我应该在.te文件中添加此规则

allow kernel oem_device:blk_file {read write};

adb pull /sys/fs/selinux/policy
adb logcat -b all -d | audit2allow -p policy
#this confirms the rule

我在此转储中找到了一些与selinux相关的文件:

https://git.rip/dumps/oneplus/oneplus7tpro/-/find_file/hotdog-user-10-QKQ1.190716.003-2009281542-release-keys

但是我不太确定应该在哪里添加规则。可能在/ vendor / etc / selinux中的某个地方。

有人知道要解决这些警告的步骤是什么,也许还可以进一步调查为什么会首先出现这些警告?

谢谢

解决方法

显示该错误的原因很简单。 kernel尝试读取/写入标有blk_file类型的oem_device

目前,您有两种选择:

  1. 如果要允许访问发生,请添加allow规则。
  2. 添加dontaudit规则,如果您只想保留日志。看到 here

规则应添加到kernel.te中。
通常,这些自定义内容会放入device/XXXXXX中,具体取决于供应商。例如,在我的树中,对于Rockchip设备,我将修改/device/rockchip/common/sepolicy/vendor/kernel.te

要重建策略,您将:

source build/envsetup.sh
lunch-yourTarget
mmm system/sepolicy

并将它们刷新到系统中(如果您是userdebug并可以重新安装):

adb root
adb remount
adb push out/target/product/YOUR_DEVICE/vendor/etc/selinux /vendor/etc/
adb push out/target/product/YOUR_DEVICE/system/etc/selinux /system/etc/
adb shell sync

adb reboot

如果无法推动它们,则需要重建并刷新系统

,

我设法通过以下命令修复了警告:

magiskpolicy --live 'allow kernel oem_device blk_file {read write open}'

“打开”权限也被授予,因为在仅允许读/写之后还会出现与其有关的另一条警告。

我还是不明白:

  1. 内核为什么要尝试访问此内容
  2. 正在尝试访问的内容
  3. 不应该处理与诸如内核之类的低级别授权相关的selinux策略
  4. 不确定如何使此修复程序永久生效(重新启动后仍然存在)。从我的研究看来,我必须在boot.img中修改某个文件,将其重新打包,然后将其推回android。

在此页面上: https://topjohnwu.github.io/Magisk/tools.html

它指定了magiskboot工具,该工具应用于此类补丁,但我没有。

A tool to unpack / repack boot images,parse / patch / extract cpio,patch dtb,hex patch binaries,and compress / decompress files with multiple algorithms.

任何发现我都会回来的。

更新: 我设法通过在引导过程中运行的后fs-data脚本在引导时永久添加了修复程序。可能不是100%修复,因为应该修补启动映像,以便magiskinit甚至在执行init之前就加载策略,但是仍然可以在启动过程结束后修复logcat中的警告

REF:

https://topjohnwu.github.io/Magisk/details.html#magisk-booting-process https://topjohnwu.github.io/Magisk/guides.html#boot-scripts

su -
cd /data/adb/post-fs-data.d
touch fix_selinux.sh
chmod +x fix_selinux.sh
vi fix_selinux.sh #add this line (and any other rules you need):
/sbin/magiskpolicy --live 'allow kernel oem_device blk_file {read write open}'

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 <select id="xxx"> SELECT di.id, di.name, di.work_type, di.updated... <where> <if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 <property name="dynamic.classpath" value="tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams['font.sans-serif'] = ['SimHei'] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -> systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping("/hires") public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate<String
使用vite构建项目报错 C:\Users\ychen\work>npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-