magiskpolicy CLI Reference Manual
Developer reference for magiskpolicy, the native Magisk utility that compiles, modifies, and injects live SELinux access vectors directly into the running Linux kernel, enabling root daemons to function in Enforcing mode without triggering audit denials.
Live SELinux Policy Patching Explained
Historically, rooting tools required setting SELinux to Permissive mode (disabling all security controls system-wide). magiskpolicy parses Android's compiled binary policy (/sys/fs/selinux/load) in kernel memory, adds targeted allow rules specifically for Magisk and module domains, and reloads the policy dynamically while keeping the system in secure Enforcing mode.
Command Modes & CLI Syntax
SEPolicy Rule Syntax Reference
magiskpolicy supports the full standard SELinux statement syntax:
| Statement Syntax | Description | Example |
|---|---|---|
allow src tgt class perm |
Grants access permissions between domains | allow magisk su_daemon process { fork signal } |
permissive type |
Sets specific type/domain to permissive mode | permissive custom_daemon_t |
type type_name [attr] |
Declares a new SELinux type and optional attributes | type my_service_t domain |
attribute attr_name |
Declares a new SELinux attribute | attribute my_domain_attr |
typeattribute type attr |
Associates an existing type with an attribute | typeattribute custom_t domain |
Practical Example: Granting Daemon File Access
Related Guides & Next Steps
Explore interconnected tutorials, module guides, and developer references related to this topic:
Android 16 QPR2 SEPolicy
AndroidExplore Android 16 binary SEPolicy standards and klogdump.
MagiskSU Developer Guide
ToolMulti-user root permissions and Mount Master namespace mode.
Technical Documentation
DocsIn-depth breakdown of MagiskInit and live SELinux patching.
Verified with Android 16 QPR2 binary SEPolicy compatibility on Magisk v30.7 (February 23, 2026).