topjohnwu / Magisk

The Magic Mask for Android
GNU General Public License v3.0
47.6k stars 12.09k forks source link

magisk 20.3 some sbin file link to root error #2247

Closed youling257 closed 4 years ago

youling257 commented 4 years ago

magisk 20.3 master android_x86:/ $ su android_x86:/ # ls -al /sbin total 884 drwxr-x--- 3 root root 360 2020-01-11 23:19 . drwxrwxrwt 19 root root 900 2020-01-11 23:19 .. lrwxrwxrwx 1 root root 9 2020-01-11 23:19 .core -> ./.magisk drwxr-xr-x 6 root root 160 2020-01-11 23:19 .magisk lrwxrwxrwx 1 root root 10 2020-01-11 23:19 adbd -> /root/adbd lrwxrwxrwx 1 root root 13 2020-01-11 23:19 healthd -> /root/healthd -rwxr-xr-x 1 root root 300940 2020-01-11 23:19 magisk lrwxrwxrwx 1 root root 8 2020-01-11 23:19 magiskhide -> ./magisk -rwxr-xr-x 1 root root 601248 2020-01-11 23:19 magiskinit lrwxrwxrwx 1 root root 12 2020-01-11 23:19 magiskpolicy -> ./magiskinit lrwxrwxrwx 1 root root 10 2020-01-11 23:19 modprobe -> ../init86d lrwxrwxrwx 1 root root 19 2020-01-11 23:19 mount.ntfs-3g -> /root/mount.ntfs-3g lrwxrwxrwx 1 root root 8 2020-01-11 23:19 resetprop -> ./magisk lrwxrwxrwx 1 root root 8 2020-01-11 23:19 su -> ./magisk lrwxrwxrwx 1 root root 12 2020-01-11 23:19 supolicy -> ./magiskinit lrwxrwxrwx 1 root root 10 2020-01-11 23:19 ueventd -> ../init86d lrwxrwxrwx 1 root root 10 2020-01-11 23:19 v86d -> /root/v86d lrwxrwxrwx 1 root root 10 2020-01-11 23:19 watchdogd -> ../init86d android_x86:/ #

magisk 20.3 revert 3a0e3c9 and d22b9c2 android_x86:/ $ su android_x86:/ # ls -al /sbin total 884 drwxr-x--- 3 root root 360 2020-01-11 23:16 . drwxrwxrwt 19 root root 900 2020-01-11 23:16 .. lrwxrwxrwx 1 root root 9 2020-01-11 23:16 .core -> ./.magisk drwxr-xr-x 6 root root 160 2020-01-11 23:16 .magisk lrwxrwxrwx 1 root root 10 2020-01-11 23:16 adbd -> /root/adbd lrwxrwxrwx 1 root root 13 2020-01-11 23:16 healthd -> /root/healthd -rwxr-xr-x 1 root root 300940 2020-01-11 23:16 magisk lrwxrwxrwx 1 root root 8 2020-01-11 23:16 magiskhide -> ./magisk -rwxr-xr-x 1 root root 601248 2020-01-11 23:16 magiskinit lrwxrwxrwx 1 root root 12 2020-01-11 23:16 magiskpolicy -> ./magiskinit lrwxrwxrwx 1 root root 14 2020-01-11 23:16 modprobe -> /root/modprobe lrwxrwxrwx 1 root root 19 2020-01-11 23:16 mount.ntfs-3g -> /root/mount.ntfs-3g lrwxrwxrwx 1 root root 8 2020-01-11 23:16 resetprop -> ./magisk lrwxrwxrwx 1 root root 8 2020-01-11 23:16 su -> ./magisk lrwxrwxrwx 1 root root 12 2020-01-11 23:16 supolicy -> ./magiskinit lrwxrwxrwx 1 root root 13 2020-01-11 23:16 ueventd -> /root/ueventd lrwxrwxrwx 1 root root 10 2020-01-11 23:16 v86d -> /root/v86d lrwxrwxrwx 1 root root 15 2020-01-11 23:16 watchdogd -> /root/watchdogd android_x86:/ #

android_x86:/ $ su android_x86:/ # ls -al /root total 2420 drwxr-x--- 2 root root 180 2020-01-12 07:19 . drwxrwxrwt 19 root root 900 2020-01-11 23:19 .. -rwxr-x--- 2 root root 1404660 2020-01-12 07:19 adbd -rwxr-x--- 2 root root 1019188 2020-01-12 07:19 healthd lrwxrwxrwx 2 root root 7 2020-01-12 07:19 modprobe -> ../init -rwxr-x--- 2 root root 35652 2016-07-21 20:54 mount.ntfs-3g lrwxrwxrwx 2 root root 7 2020-01-12 07:19 ueventd -> ../init -rwxr-x--- 2 root root 13744 2020-01-12 07:19 v86d lrwxrwxrwx 2 root root 7 2020-01-12 07:19 watchdogd -> ../init android_x86:/ #

youling257 commented 4 years ago

today retest magisk 20.2, ls -al /sbin total 3252 drwxr-xr-x 3 0 0 260 Jan 11 15:43 . drwxrwxrwt 19 0 0 860 Jan 11 15:43 .. drwxr-xr-x 4 0 0 100 Jan 11 15:43 .magisk -rwxr-x--- 2 0 0 1404660 Jan 11 2020 adbd -rwxr-x--- 2 0 0 1019188 Jan 11 2020 healthd -rwxr-xr-x 1 0 0 300940 Jan 11 15:43 magisk lrwxrwxrwx 1 0 0 8 Jan 11 15:43 magiskhide -> ./magisk -rwxr-xr-x 1 0 0 584864 Jan 11 15:43 magiskinit lrwxrwxrwx 1 0 0 12 Jan 11 15:43 magiskpolicy -> ./magiskinit lrwxrwxrwx 1 0 0 8 Jan 11 15:43 resetprop -> ./magisk lrwxrwxrwx 1 0 0 8 Jan 11 15:43 su -> ./magisk lrwxrwxrwx 1 0 0 12 Jan 11 15:43 supolicy -> ./magiskinit -rwxr-x--- 2 0 0 13744 Jan 11 2020 v86d

the sbin some file create error is the "No modules load on Android 6" reason, not fixed.

youling257 commented 4 years ago

d22b9c2 搞坏了sbin里面的文件链接,这小问题能不能修复? @topjohnwu

youling257 commented 4 years ago

u0_a116@NX16A8116K:/ $ su root@NX16A8116K:(unreachable) # ls -al /sbin drwxr-xr-x root root 2020-01-11 20:53 .magisk lrwxrwxrwx root root 2020-01-11 20:53 adbd -> /root/adbd lrwxrwxrwx root root 2020-01-11 20:53 healthd -> /root/healthd -rwxr-xr-x root root 300940 2020-01-11 20:53 magisk lrwxrwxrwx root root 2020-01-11 20:53 magiskhide -> ./magisk -rwxr-xr-x root root 601248 2020-01-11 20:53 magiskinit lrwxrwxrwx root root 2020-01-11 20:53 magiskpolicy -> ./magiskinit lrwxrwxrwx root root 2020-01-11 20:53 resetprop -> ./magisk lrwxrwxrwx root root 2020-01-11 20:53 slideshow -> /root/slideshow lrwxrwxrwx root root 2020-01-11 20:53 su -> ./magisk lrwxrwxrwx root root 2020-01-11 20:53 supolicy -> ./magiskinit root@NX16A8116K:(unreachable)

lrwxrwxrwx root root 2020-01-12 10:17 .core -> ./.magisk drwxr-xr-x root root 2020-01-12 10:17 .magisk lrwxrwxrwx root root 2020-01-12 10:17 adbd -> /root/adbd lrwxrwxrwx root root 2020-01-12 10:17 healthd -> /root/healthd -rwxr-xr-x root root 300940 2020-01-12 10:17 magisk lrwxrwxrwx root root 2020-01-12 10:17 magiskhide -> ./magisk -rwxr-xr-x root root 601248 2020-01-12 10:17 magiskinit lrwxrwxrwx root root 2020-01-12 10:17 magiskpolicy -> ./magiskinit lrwxrwxrwx root root 2020-01-12 10:17 resetprop -> ./magisk lrwxrwxrwx root root 2020-01-12 10:17 slideshow -> /root/slideshow lrwxrwxrwx root root 2020-01-12 10:17 su -> ./magisk lrwxrwxrwx root root 2020-01-12 10:17 supolicy -> ./magiskinit lrwxrwxrwx root root 2020-01-12 10:17 ueventd -> /root/ueventd lrwxrwxrwx root root 2020-01-12 10:17 watchdogd -> /root/watchdogd

youling257 commented 4 years ago

这还不能说明问题吗?@topjohnwu

shakalaca commented 4 years ago

其實 https://github.com/topjohnwu/Magisk/commit/3a0e3c98f77f6344ffb73d81b1a4336c2ef56125 有修正 https://github.com/topjohnwu/Magisk/commit/d22b9c26b66c0ecea53abdc4729f1014982427b3 的問題,只差 https://github.com/topjohnwu/Magisk/commit/3a0e3c98f77f6344ffb73d81b1a4336c2ef56125#diff-991b6b6b74bbc9f3eaab02fe63d2ee6fR231 少了個 null terminator,耐心點下一版應該就會修正了 ;)

youling257 commented 4 years ago

@shakalaca 所以补丁是怎样?我可以自己编译

youling257 commented 4 years ago

测试了Add null terminator补丁 android_x86:/ # ls -al /sbin total 884 drwxr-x--- 3 root root 340 2020-01-16 00:31 . drwxrwxrwt 19 root root 900 2020-01-16 00:31 .. drwxr-xr-x 6 root root 140 2020-01-16 00:31 .magisk lrwxrwxrwx 1 root root 10 2020-01-16 00:31 adbd -> /root/adbd lrwxrwxrwx 1 root root 13 2020-01-16 00:31 healthd -> /root/healthd -rwxr-xr-x 1 root root 300940 2020-01-16 00:31 magisk lrwxrwxrwx 1 root root 8 2020-01-16 00:31 magiskhide -> ./magisk -rwxr-xr-x 1 root root 601248 2020-01-16 00:31 magiskinit lrwxrwxrwx 1 root root 12 2020-01-16 00:31 magiskpolicy -> ./magiskinit lrwxrwxrwx 1 root root 7 2020-01-16 00:31 modprobe -> ../init lrwxrwxrwx 1 root root 19 2020-01-16 00:31 mount.ntfs-3g -> /root/mount.ntfs-3g lrwxrwxrwx 1 root root 8 2020-01-16 00:31 resetprop -> ./magisk lrwxrwxrwx 1 root root 8 2020-01-16 00:31 su -> ./magisk lrwxrwxrwx 1 root root 12 2020-01-16 00:31 supolicy -> ./magiskinit lrwxrwxrwx 1 root root 7 2020-01-16 00:31 ueventd -> ../init lrwxrwxrwx 1 root root 10 2020-01-16 00:31 v86d -> /root/v86d lrwxrwxrwx 1 root root 7 2020-01-16 00:31 watchdogd -> ../init modprobe ueventd watchdogd直接链接到了../init

一会儿找martyfender测试下他的Androidx86上又有什么奇妙变化

shakalaca commented 4 years ago

表面現象就是少了 \0,不過如 @topjohnwu 所說程式碼裡面使用的 https://github.com/topjohnwu/Magisk/blob/master/native/jni/utils/xwrap.cpp#L287-L295 已經做了。或許你可以編譯一下這個簡單的程式來看看 readlinkat 的回傳值是否正確 ? https://gist.github.com/shakalaca/fca3088b8c8103a4da5529b893eedd99

shakalaca commented 4 years ago

@youling257 方便的話給一下指令 mount 與 df 的輸出結果

youling257 commented 4 years ago

https://github.com/topjohnwu/Magisk/issues/2182#issuecomment-574956217 试了,那个补丁对他没用,能解决他的问题再说,我的问题跟他的就是同一个问题,他那是oem定制Android ia 6.0。 别光针对我们Androidx86 for pc独特的进入Android之前的mount,那不是问题。 none on / type rootfs (rw,seclabel) proc on /proc type proc (rw,relatime) sys on /sys type sysfs (rw,seclabel,relatime) tmpfs on /android type tmpfs (rw,seclabel,relatime) /dev/mmcblk0p3 on /mnt type ext4 (rw,seclabel,noatime) /dev/block/loop0 on /sfs type squashfs (ro,seclabel,noatime) /dev/block/loop1 on /android/system type ext4 (ro,seclabel,noatime) /dev/mmcblk0p3 on /android/system/lib/modules type ext4 (rw,seclabel,noatime) /dev/mmcblk0p3 on /android/system/lib/firmware type ext4 (rw,seclabel,noatime) /dev/mmcblk0p3 on /android/su type ext4 (rw,seclabel,noatime) /dev/mmcblk0p3 on /android/system/etc/init.sh type ext4 (rw,seclabel,noatime) /dev/mmcblk0p3 on /android/system/etc/modules.blacklist type ext4 (rw,seclabel,noatime) /dev/mmcblk0p3 on /android/system/etc/init type ext4 (rw,seclabel,noatime) /dev/mmcblk0p3 on /android/data type ext4 (rw,seclabel,noatime) tmpfs on /android/dev type tmpfs (rw,seclabel,nosuid,relatime,mode=755) devpts on /android/dev/pts type devpts (rw,seclabel,relatime,mode=600,ptmxmode=000) proc on /android/proc type proc (rw,relatime) sysfs on /android/sys type sysfs (rw,seclabel,relatime) selinuxfs on /android/sys/fs/selinux type selinuxfs (rw,relatime) /sys/kernel/debug on /android/sys/kernel/debug type debugfs (rw,seclabel,relatime,mode=755) none on /android/acct type cgroup (rw,seclabel,relatime,cpuacct) tmpfs on /android/mnt type tmpfs (rw,seclabel,relatime,mode=755,gid=1000) none on /android/config type configfs (rw,relatime) none on /android/dev/memcg type cgroup (rw,seclabel,relatime,memory) none on /android/dev/cpuctl type cgroup (rw,seclabel,relatime,cpu) none on /android/dev/cpuset type cgroup (rw,seclabel,relatime,cpuset,noprefix,release_agent=/sbin/cpuset_release_agent) pstore on /android/sys/fs/pstore type pstore (rw,seclabel,relatime) /dev/mmcblk0p3 on /android/system/xbin/su type ext4 (rw,seclabel,noatime) /dev/mmcblk0p3 on /android/system/xbin/su type ext4 (rw,seclabel,noatime) /dev/mmcblk0p3 on /android/system/xbin type ext4 (rw,seclabel,noatime) none on /android/cache type tmpfs (rw,seclabel,nosuid,nodev,noatime) tmpfs on /android/storage type tmpfs (rw,seclabel,relatime,mode=755,gid=1000) tracefs on /android/sys/kernel/debug/tracing type tracefs (rw,seclabel,relatime) /dev/mmcblk0p3 on /android/system/bin/vold type ext4 (rw,seclabel,noatime)

tmpfs on /android/sbin type tmpfs (rw,seclabel,relatime,mode=755) /sbin/.magisk/block/system on /android/sbin/.magisk/mirror/system type ext4 (ro,seclabel,noatime) /dev/block/mmcblk0p3 on /android/data/f2fs type ext4 (rw,seclabel,noatime) /dev/mmcblk0p3 on /android/.bash_history type ext4 (rw,seclabel,noatime) /dev/mmcblk0p3 on /android/.ash_history type ext4 (rw,seclabel,noatime) /dev/mmcblk0p3 on /android/sbin/.magisk/mirror/data type ext4 (rw,seclabel,noatime) /dev/mmcblk0p3 on /android/sbin/.magisk/modules type ext4 (rw,seclabel,noatime) 就是要在启动magisk daemon之前,先启动supersu,这也不是问题。

shakalaca commented 4 years ago

@youling257 一次解決一件事情不要混在一起講。

  1. /sbin 目錄下的 symbolic link 如果是用最新 canary 可否正確連結到檔案 ? 我根據你前面的 output 理解到在你的裝置上 symbolic link 會出錯,如果系統沒有先去找 /root 下的程式先執行,某些作業系統的功能將無法使用,所以我才出 patch 看看是否能修正這個狀況。
  2. Magisk module 無法載入的問題,我知道你有自行編譯一版 revert 3a0e3c9 與 d22b9c2,請問這一版可以正常載入 magisk module 嗎?
  3. 你的檔案系統內容看起來跟 martyfender 的不太一樣,不太理解你的 test build 可以怎麼幫助他。

根據經驗某些平台的 system call 會不如預期,以現在的例子來說有可能跟檔案系統有關也有可能跟版本過舊潛藏的 bug 有關,要 debug 不難,環境越簡單越好:原始的系統組態,安裝 patch 過的 boot.img,然後不裝任何模組,觀察所有相關 log,一次改變一個可能變因,然後重複嘗試直到解決。你的系統又有模組又有 supersu,到底原先 magisk 是否可以正常使用也看不出來。Magisk 的平台相容不好做,在沒有裝置的前提下 @topjohnwu 也只能靠單方面的 log 來推測到底出了什麼問題,如果沒法提出有效的資訊來處理這些相容的 issue,@topjohnwu 也只能一段時間後 close 這筆 issue,長期來講對 Magisk 的核心發展是種傷害。

youling257 commented 4 years ago

对于martyfender,只要把symlink link弄成这样,就能加载模块,revert俩补丁symlink link可以弄成这样, lrwxrwxrwx root root 2020-01-12 10:17 .core -> ./.magisk drwxr-xr-x root root 2020-01-12 10:17 .magisk lrwxrwxrwx root root 2020-01-12 10:17 adbd -> /root/adbd lrwxrwxrwx root root 2020-01-12 10:17 healthd -> /root/healthd -rwxr-xr-x root root 300940 2020-01-12 10:17 magisk lrwxrwxrwx root root 2020-01-12 10:17 magiskhide -> ./magisk -rwxr-xr-x root root 601248 2020-01-12 10:17 magiskinit lrwxrwxrwx root root 2020-01-12 10:17 magiskpolicy -> ./magiskinit lrwxrwxrwx root root 2020-01-12 10:17 resetprop -> ./magisk lrwxrwxrwx root root 2020-01-12 10:17 slideshow -> /root/slideshow lrwxrwxrwx root root 2020-01-12 10:17 su -> ./magisk lrwxrwxrwx root root 2020-01-12 10:17 supolicy -> ./magiskinit lrwxrwxrwx root root 2020-01-12 10:17 ueventd -> /root/ueventd lrwxrwxrwx root root 2020-01-12 10:17 watchdogd -> /root/watchdogd

youling257 commented 4 years ago

而我的变成了watchdogd -> ../init86d modprobe -> ../init86d ueventd -> ../init86d这莫名其妙的链接,是因为Simplify rootfs persist mount,而这个补丁是因为他看了https://github.com/topjohnwu/Magisk/issues/2182#issuecomment-571978483 这里的log https://github.com/topjohnwu/Magisk/issues/2182#issuecomment-571978483 https://github.com/topjohnwu/Magisk/issues/2182#issuecomment-572433057 https://github.com/topjohnwu/Magisk/issues/2182#issuecomment-572617206

youling257 commented 4 years ago

把我的搞成了watchdogd -> ../init modprobe -> ../init ueventd -> ../init或者watchdogd -> ../init86d ueventd -> ../init86d modprobe -> ../init86d,我的能加载模块又如何?

通过新的补丁把symlink搞得跟revert d22b9c2的symlink一样,我的问题和martyfender的问题才算解决

shakalaca commented 4 years ago

OK 好喔,反正你可以自己編譯出你們平台能用的版本,那我想也沒什麼問題了。

martyfender commented 4 years ago

Do you have a build I can test out on my Nextbook x86 device? Thanks

shakalaca commented 4 years ago

@martyfender try the latest canary build

martyfender commented 4 years ago

This finally solved my issue of modules not loading on my Nextbook Ares 8A, x86 devices. Thank You