topjohnwu / Magisk

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

no Magisk after flashing, "cp: can't preserve ownership... Operation not permitted" #8139

Closed MCOfficer closed 3 months ago

MCOfficer commented 3 months ago

Device: Nokia 3.1 (TA-1063) Android version: 10 Magisk version name: 27002 Magisk version code: 19f15f16 (27002) (D)

Freshly unlocked bootloader, no previous root or custom rom. Dumped partitions with mtkclient, checked which A/B slot is active, then patched boot_b.bin with Magisk.

Magisk log [magisk_install_log_2024-06-18T12.36.58.log](https://github.com/user-attachments/files/15886746/magisk_install_log_2024-06-18T12.36.58.log) ``` - Device platform: arm64-v8a - Installing: 19f15f16 (27002) - Copying image to cache - Unpacking boot image Parsing boot image: [/data/user_de/0/com.topjohnwu.magisk/install/boot.img] HEADER_VER [2] KERNEL_SZ [7887733] RAMDISK_SZ [6852029] SECOND_SZ [0] RECOV_DTBO_SZ [0] DTB_SZ [71673] OS_VERSION [10.0.0] OS_PATCH_LEVEL [2021-08] PAGESIZE [2048] NAME [] CMDLINE [bootopt=64S3,32N2,64N2 buildvariant=user veritykeyid=id:8f56f02c61394639f13af4e8cfe02d087e41b936] CHECKSUM [9b759ee7f9065936ee9f3a7b88e8e34c1597defa000000000000000000000000] KERNEL_DTB_SZ [71609] KERNEL_FMT [gzip] RAMDISK_FMT [gzip] AVB1_SIGNED - Checking ramdisk status Loading cpio: [ramdisk.cpio] - Stock boot image detected - Patching ramdisk resetprop: get prop [ro.crypto.state]: [encrypted] Loading cpio: [ramdisk.cpio] - Pre-init storage partition: persist Add file [init] (100750) Create directory [overlay.d] (0750) Create directory [overlay.d/sbin] (0750) Add file [overlay.d/sbin/magisk.xz] (100644) Add file [overlay.d/sbin/stub.xz] (100644) Patch with flag KEEPVERITY=[true] KEEPFORCEENCRYPT=[true] Loading cpio: [ramdisk.cpio.orig] Backup [init] -> [.backup/init] Record new entry: [overlay.d] -> [.backup/.rmlist] Record new entry: [overlay.d/sbin] -> [.backup/.rmlist] Record new entry: [overlay.d/sbin/magisk.xz] -> [.backup/.rmlist] Record new entry: [overlay.d/sbin/stub.xz] -> [.backup/.rmlist] Create directory [.backup] (0000) Add file [.backup/.magisk] (100000) Dumping cpio: [ramdisk.cpio] Loading dtbs from [dtb] Loading dtbs from [dtb] Loading dtbs from [kernel_dtb] Loading dtbs from [kernel_dtb] Patch @ 0x00FFFBE8 [736B69705F696E697472616D667300] -> [77616E745F696E697472616D667300] - Repacking boot image Parsing boot image: [/data/user_de/0/com.topjohnwu.magisk/install/boot.img] HEADER_VER [2] KERNEL_SZ [7887733] RAMDISK_SZ [6852029] SECOND_SZ [0] RECOV_DTBO_SZ [0] DTB_SZ [71673] OS_VERSION [10.0.0] OS_PATCH_LEVEL [2021-08] PAGESIZE [2048] NAME [] CMDLINE [bootopt=64S3,32N2,64N2 buildvariant=user veritykeyid=id:8f56f02c61394639f13af4e8cfe02d087e41b936] CHECKSUM [9b759ee7f9065936ee9f3a7b88e8e34c1597defa000000000000000000000000] KERNEL_DTB_SZ [71609] KERNEL_FMT [gzip] RAMDISK_FMT [gzip] AVB1_SIGNED Repack to boot image: [new-boot.img] HEADER_VER [2] KERNEL_SZ [7891270] RAMDISK_SZ [7104030] SECOND_SZ [0] RECOV_DTBO_SZ [0] DTB_SZ [71673] OS_VERSION [10.0.0] OS_PATCH_LEVEL [2021-08] PAGESIZE [2048] NAME [] CMDLINE [bootopt=64S3,32N2,64N2 buildvariant=user veritykeyid=id:8f56f02c61394639f13af4e8cfe02d087e41b936] CHECKSUM [aa2048cd355a109fcb1a64031c95773f530c8d03000000000000000000000000] **************************** Output file is written to /storage/emulated/0/Download/magisk_patched-27002_bE4nD.img **************************** cp: can't preserve ownership of 'busybox': Operation not permitted cp: can't preserve ownership of 'magisk': Operation not permitted cp: can't preserve ownership of 'magisk32': Operation not permitted cp: can't preserve ownership of 'magiskboot': Operation not permitted cp: can't preserve ownership of 'magiskinit': Operation not permitted cp: can't preserve ownership of 'magiskpolicy': Operation not permitted - All done! ```

boot_b.bin.gz magisk_patched-27002_bE4nD.img.gz

Then flash:

❯ adb reboot bootloader

❯ fastboot flash boot_b magisk_patched-27002_bE4nD.img 
Sending 'boot_b' (24576 KB)                        OKAY [  0.873s]
Writing 'boot_b'                                   OKAY [  1.198s]
Finished. Total time: 2.075s

❯ fastboot reboot
Rebooting                                          OKAY [  0.000s]
Finished. Total time: 1.054s

Confirm slot B is indeed still active after the reboot:

❯ adb shell /bin/getprop ro.boot.slot_suffix                       
_b

But no root, Magisk app also says "Installed: N/A"

❯ adb shell magisk
/system/bin/sh: magisk: inaccessible or not found

(might be a duplicate of #8081)

yujincheng08 commented 3 months ago

please provide bugreport as soon as the device boots.

MCOfficer commented 3 months ago

The device boots & functions fine, on the surface nothing has changed compared to stock ROM.

bugreport-Essential2_00WW-QP1A.190711.020-2024-06-18-16-09-40.zip

(this bugreport was generated with the patched boot_b.img applied, as detailed above)

yujincheng08 commented 3 months ago

I don't think this bugreport was captured right after boot as requested, because logs are quite late.

Further, I saw unofficial magisk in your log, and we have no support for them.

Last, I think /sbin/su can grant you root.

Close.

MCOfficer commented 3 months ago

I don't think this bugreport was captured right after boot as requested, because logs are quite late.

Ah, i misunderstood. Here's a bugreport captured immediately after a reboot: bugreport-Essential2_00WW-QP1A.190711.020-2024-06-18-16-29-54.zip

Further, I saw unofficial magisk in your log, and we have no support for them.

I have an unofficial magisk app (Kitsune) installed from an earlier attempt, (nevermind, apparently i already removed that. i don't know what app you saw...)

everything in this issue relates to offical magisk. I made sure to flash my clean, stock boot_b.bin to undo this attempt, and only used official magisk in the steps detailed above. If you are not convinced, i can wipe all traces of Kitsune and try to reproduce once more. Please reopen.

Last, I think /sbin/su can grant you root.

❯ adb shell /sbin/su
/system/bin/sh: /sbin/su: inaccessible or not found
yujincheng08 commented 3 months ago

the log does not help because there're full of garbage.

try adb shell ls /sbin and adb shell /sbin/magisk su

MCOfficer commented 3 months ago

Ah, that turned up something:

❯ adb shell ls /sbin
ls: /sbin/stub.apk: Permission denied
ls: /sbin/magisk: Permission denied
ls: /sbin/magiskinit: Permission denied
resetprop
su
supolicy

❯ adb shell /sbin/magisk su
/system/bin/sh: /sbin/magisk: inaccessible or not found

If you know of a way to generate cleaner logs, i'd be happy to do that.


Edit in case this helps:

❯ adb shell ls -la /sbin
ls: /sbin/stub.apk: Permission denied
ls: /sbin/magisk: Permission denied
total 4
ls: /sbin/magiskinit: Permission denied
drwxr-xr-x  3 root root  180 2024-06-18 16:27 .
drwxr-xr-x 20 root root 4096 2009-01-01 01:00 ..
drwx--x--x  7 root root  160 2024-06-18 16:27 .magisk
lrwxrwxrwx  1 root root    8 2024-06-18 16:27 resetprop -> ./magisk
lrwxrwxrwx  1 root root    8 2024-06-18 16:27 su -> ./magisk
lrwxrwxrwx  1 root root   14 2024-06-18 16:27 supolicy -> ./magiskpolicy
MCOfficer commented 2 months ago

Since there was no unofficial magisk involved, and things in /sbin are clearly not working as expected, can this be reopened?