android - 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://source.android.com/security/selinux/customize#android-o
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 相关的文件:
但我不太确定我应该在哪里添加规则..可能在 /vendor/etc/selinux..
有谁知道修复这些警告的步骤是什么,并可能进一步深入调查为什么它们首先发生?
谢谢
解决方案
我设法用这个命令修复了警告:
magiskpolicy --live 'allow kernel oem_device blk_file {read write open}'
'open' 权限也被授予,因为在只允许读/写之后会出现另一个与之相关的警告。
我仍然无法理解:
- 为什么内核试图访问它
- 究竟试图访问什么
- magisk 不应该处理与内核等低级授权相关的 selinux 策略
- 不知道我怎样才能使这个修复永久化(在重新启动时持续存在)。从我的研究看来,我必须修改 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.
我会带着任何发现回来。
更新:我设法在启动时使用在启动过程中运行的 post-fs-data 脚本永久添加修复程序。它可能不是 100% 修复,因为应该修补引导映像,以便 magiskinit 甚至在执行 init 之前加载策略,但是它仍然在引导过程结束后修复 logcat 中的警告
参考:
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}'
推荐阅读
- c - 为什么 gcc 不链接 SDL 2.0 C 项目?(苹果系统)
- python - 将烧瓶应用程序推送到 heroku 时未找到包错误
- jquery - 无法在单击时动态更改按钮上的 div 内容
- git - 如何完全重新设置主分支中的所有提交?
- node.js - 跨多个文件具有相同名称的非导出变量导致 TS2403
- php - Symfony / Doctrine 中的映射异常:在“App\DocumentBundle\Entity\Document#file”中找不到目标实体 App\DocumentBundle\File
- pyspark - 创建 pyspark 数据框时如何将小数作为值传递?
- html - 如何在引导程序中制作下拉列表?
- java - 如果我在方法中初始化模型,为什么我不能访问它?
- bash - 如何解析 csv 文件以在第 2 列的文件中查找“失败”并找到第 7 列的平均值