topjohnwu / Magisk

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

Magisk canary (19305) requires MagiskHide to be toggled off/on to work #1654

Closed kmdm closed 4 years ago

kmdm commented 5 years ago

Follow up from #1651 using canary.

I've been using this ROM on my Nexus 7 (2013) (deb): https://forum.xda-developers.com/nexus-7-2013/development/rom-lineageos-16-0-t3903286

Works absolutely fine with Magisk v18.1 and I can pass both basic and cts profiles.

After upgrading to Magisk to the latest canary both basic and cts profiles return false and fail.

magisk.log recovery last_log

Downgrading to Magisk v18.1 fixes the basic & cts profile failures.

kmdm commented 5 years ago

Magisk Manager (canary) - SafetyNet failed Magisk Manager (v18.1 after downgrade) - SafetyNet passed

Didgeridoohan commented 5 years ago

Just to make sure, have you tried toggling MagiskHide off and on in the Manager settings?

mark-kruz commented 5 years ago

have you tried rebooting? my s8 sometimes failed safetynet after a magisk update but would work again after a reboot

osm0sis commented 5 years ago

Is this still an issue on 19305?

kmdm commented 5 years ago

I'll re-test tonight on 19305 and also toggle magiskhide in both the UI and CLI.

kmdm commented 5 years ago

Toggling magiskhide off/on on settings worked (on 19305). Sorry for the drama.

kmdm commented 5 years ago

Although, actually, I just tried a reboot and it failed again. It seems I have to toggle it in settings after every reboot which doesn't seem right...

Didgeridoohan commented 5 years ago

That's actually good (and I was kind of hoping for it)... I've seen some reports of having to toggle MagiskHide off and on after every reboot, but so far noone's been bothered to create any proper report for it.

A boot logcat might show more.

kmdm commented 5 years ago

bootlog.log magisk.log

Didgeridoohan commented 5 years ago

Awesome. Maybe you should also edit the title to more closely match the actual issue. Makes it easier for @topjohnwu.

kmdm commented 5 years ago

I can build Magisk now so when I get time I'll run through git bisect and try to identify the commit causing the issue.

topjohnwu commented 5 years ago

@alexa-v2 clear the data of Play Store. And also, your issue is unrelated to this one

kmdm commented 5 years ago

The breaking commit for me is 4fcdcd9

If I revert that on the latest master(-ish) it works fine.

kmdm commented 5 years ago

I'm investigating this further...

I've not compared with the commit reverted but it looks like when magiskhide starts from boot it yields:

proc_monitor: nothing to monitor, wait for signal

And

** late_start service mode running

I see no evidence of it actually starting to ptrace the zygote process. Then when you toggle disable/enable in magiskhide it then immediately starts ptrace'ing the zygote process and things work as expected.

(Don't ask me how this is relevant to the commit highlighted... :-))

kmdm commented 5 years ago

I believe this is a race condition where the first call to check_zygotes() in proc_monitor.cpp:proc_monitor() doesn't detect any zygote processes. (Perhaps parsing the packages.xml was "slow enough").

I've created a fix for this with the relevant log output being:

07-02 19:40:09.051   214   222 D Magisk  : hide_list: initialize
07-02 19:40:09.051   214   222 I Magisk  : hide_list init: [com.google.android.gms/com.google.android.gms.unstable]
07-02 19:40:09.061   214   222 I Magisk  : hide_list init: [org.microg.gms.droidguard/com.google.android.gms.unstable]
07-02 19:40:09.070   214   222 D Magisk  : Looking for initial zygotes...
07-02 19:40:09.277   214   222 D Magisk  : Looking for initial zygotes...
07-02 19:40:09.492   214   222 D Magisk  : Looking for initial zygotes...
07-02 19:40:10.140   214   356 I Magisk  : ** late_start service mode running
07-02 19:40:10.140   214   356 D Magisk  : magiskdb: query magiskhide=[1]
07-02 19:40:10.140   214   356 I Magisk  : * Running service.d scripts
07-02 19:40:10.140   214   356 I Magisk  : * Running module service scripts
07-02 19:40:10.255   214   222 D Magisk  : Looking for initial zygotes...
07-02 19:40:10.523   214   222 D Magisk  : Looking for initial zygotes...
07-02 19:40:10.737   214   222 D Magisk  : Looking for initial zygotes...
07-02 19:40:10.745   214   222 D Magisk  : proc_monitor: ptrace zygote PID=[225]
07-02 19:40:10.955   214   222 D Magisk  : Found initial zygotes!

You can review the fix here and if you'd like a pull request I'm happy to provide one:

https://github.com/topjohnwu/Magisk/compare/master...kmdm:issue_1654

(I'm happy to fix-up the log messages and white-spacing too)

mo123 commented 5 years ago

I believe this is a race condition where the first call to check_zygotes() in proc_monitor.cpp:proc_monitor() doesn't detect any zygote processes. (Perhaps parsing the packages.xml was "slow enough").

I've created a fix for this with the relevant log output being:

07-02 19:40:09.051   214   222 D Magisk  : hide_list: initialize
07-02 19:40:09.051   214   222 I Magisk  : hide_list init: [com.google.android.gms/com.google.android.gms.unstable]
07-02 19:40:09.061   214   222 I Magisk  : hide_list init: [org.microg.gms.droidguard/com.google.android.gms.unstable]
07-02 19:40:09.070   214   222 D Magisk  : Looking for initial zygotes...
07-02 19:40:09.277   214   222 D Magisk  : Looking for initial zygotes...
07-02 19:40:09.492   214   222 D Magisk  : Looking for initial zygotes...
07-02 19:40:10.140   214   356 I Magisk  : ** late_start service mode running
07-02 19:40:10.140   214   356 D Magisk  : magiskdb: query magiskhide=[1]
07-02 19:40:10.140   214   356 I Magisk  : * Running service.d scripts
07-02 19:40:10.140   214   356 I Magisk  : * Running module service scripts
07-02 19:40:10.255   214   222 D Magisk  : Looking for initial zygotes...
07-02 19:40:10.523   214   222 D Magisk  : Looking for initial zygotes...
07-02 19:40:10.737   214   222 D Magisk  : Looking for initial zygotes...
07-02 19:40:10.745   214   222 D Magisk  : proc_monitor: ptrace zygote PID=[225]
07-02 19:40:10.955   214   222 D Magisk  : Found initial zygotes!

You can review the fix here and if you'd like a pull request I'm happy to provide one:

master...kmdm:issue_1654

(I'm happy to fix-up the log messages and white-spacing too)

Can you provide the update channel command I can use to download Magisk from your repo with your fix included for Magisk Manager Canary build? I can't remember how the custom update channel command works.

topjohnwu commented 5 years ago

@mo123 I plan to incorporate the fix into Magisk soon, no worries

topjohnwu commented 5 years ago

@kmdm is this still an issue for you?

aziztcf commented 5 years ago

Problem still exists with latest beta for me.