Superuser Client & Architecture

MagiskSU (su) Developer Reference

Developer reference for MagiskSU (the su binary), Magisk's isolated, multi-user privilege elevation daemon. Covers command-line arguments, Mount Master mode (--mount-master), socket IPC, and programmatic root execution.

MagiskSU Security Architecture

MagiskSU communicates with the central magiskd daemon via a secure UNIX domain socket (/data/adb/magisk/magisk64). The client process passes the calling application's UID and PID to the daemon, which verifies authorization against SQLite settings (/data/adb/magisk.db), transitions SELinux domain to u:r:magisk:s0, and forks the elevated shell.

CLI Command Syntax & Flags

su Binary Usage
# Start an interactive root shell: $su # Execute a single command and return: $su -c "setenforce 1" # Mount Master Mode (Execute in global init mount namespace): $su -M -c "ls /mnt/runtime/default" $su --mount-master # Isolated Mount Namespace (Changes do not affect other processes): $su -mm # Print MagiskSU version string / code: $su -v $su -V

Understanding Mount Master Mode (--mount-master / -M)

On Android, every application and process runs within an isolated Linux Mount Namespace. Standard mounts executed in normal su are invisible to other apps. Using su --mount-master (or su -M) forces the root shell into the root init namespace, granting full access to all dynamic storage mounts, loop devices, and external SD cards.

Programmatic Root Integration for Android Apps

To execute root commands reliably within Android applications via Java/Kotlin:

Java ProcessBuilder Pattern
Process process = new ProcessBuilder("su", "-c", "echo 'Root Verified'").start(); BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); String output = reader.readLine(); int exitCode = process.waitFor();
Source & Verification Standard

Verified against official upstream repository topjohnwu/Magisk on Magisk v30.7 (February 23, 2026).