Closed Bug 1525401 Opened 2 years ago Closed 2 years ago

Magisk su 0 id will hang on Magisk higher than 17.3


(Testing :: Mozbase, enhancement, P3)

Version 3


(firefox68 fixed)

Tracking Status
firefox68 --- fixed


(Reporter: Bebe, Assigned: bc)




(2 files)

If Magisk version is higher than 17.3 will hang when executing su 0 id.

This blocks any unit testing locally

See Also: → 1482873

:bc I know you fixed a similar issue do you have time to take a look?

running su -c id returns:

mozdevice.adb.ADBProcessError: args: adb wait-for-device shell su -c id; echo adb_returncode=$?, exitcode: 1, stdout: uid=0(root) gid=0(root) groups=0(root) context=u:r:magisk:s0

annd su 0 id hangs

Flags: needinfo?(bob)

this is what I get in console:

$ adb shell su -c id
uid=0(root) gid=0(root) groups=0(root) context=u:r:magisk:s0


$ adb shell su -c id; echo adb_returncode=$?
uid=0(root) gid=0(root) groups=0(root) context=u:r:magisk:s0

Not sure why we get exitcode 1 in python

The fact that is has a non-zero exit code for su -c id causes it to fall back to checking su 0 id which hits the hang.

I would suggest either using an older version, I have installed, or opening an issue with Failing that, a different rooting method could be used. Is there a need for a version of 17.3 or later?

What type of device and version of android are you using?

(In reply to Florin Strugariu [:Bebe] from comment #3)


adb shell su -c id;echo $?
uid=0(root) gid=0(root) groups=0(root) context=u:r:magisk:s0

Not sure why we get exitcode 1 in python

That isn't doing what you think it is doing. The echo $? is being executed on your machine, not the device. It is effectively doing

adb shell su -c id
echo $?

Flags: needinfo?(bob)
Priority: -- → P3

chartjes and I went through a pdb session on this with android 9 and the latest magisk. I have some clues but I'll need to upgrade my magisk and possible android to 9 to reproduce. I'll look asap as soon as I can afford to hork my device later today or tomorrow.

Assignee: nobody → bob
Flags: needinfo?(bob)

It turns out that the first time we call ADBDevice.shell_output("su -c id") it will succeed in returning the appropriate output but the exitcode will be 1 since selinux is still enforcing. We can work around it by using ADBProcess directly to attempt to set selinux to permissive.

I've also changed the failure messages to include the exception though it wouldn't have been that much more informative in this case. Without setting selinux permissive prior to the check, the error messages would have read

Check for su -c failed: args: adb wait-for-device shell su -c id; echo adb_returncode=$?, exitcode: 1, stdout: uid=0(root) gid=0(root) groups=0(root) context=u:r:magisk:s0

Which would have told us more clearly that the command succeeded even though the exitcode was non-zero which might have helped debug this sooner.

With this patch Pixel2 Android 9 with Magisk v19 works for me locally. No idea on overall stability with regard to hangs or whatever. I'll investigate that later.

try run:

gbrown: I haven't yet done the phab dance. Would you mind putting this into phabricator for me?

Flags: needinfo?(bob)
Attachment #9054456 - Flags: feedback?(gbrown)
Comment on attachment 9054456 [details] [diff] [review]

Review of attachment 9054456 [details] [diff] [review]:

I imported your patch and preserved the author as you locally, but when I uploaded to phab, the author was changed to me. I don't know how to get around that.
Attachment #9054456 - Flags: feedback?(gbrown) → feedback+
Pushed by
[mozdevice 3.0.2] work around need to invoke su -c setenforce 0 prior to check for su support when using Magisk later than 17.3, r=gbrown.
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla68
You need to log in before you can comment on or make changes to this bug.