[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2025-07-27 UTC"],[],[],null,["# Security-Enhanced Linux in Android\n\nAs part of the Android [security model](/docs/security), Android uses Security-Enhanced Linux (SELinux) to enforce\nmandatory access control (MAC) over all processes, even processes running with\nroot/superuser privileges (Linux capabilities). Many companies and organizations\nhave contributed to Android's\n[SELinux\nimplementation](https://android.googlesource.com/platform/external/selinux/). With SELinux, Android can better protect and confine system\nservices, control access to application data and system logs, reduce the effects\nof malicious software, and protect users from potential flaws in code on mobile\ndevices.\n\nSELinux operates on the principle of default denial: Anything not explicitly\nallowed is denied. SELinux can operate in two global modes:\n\n- *Permissive* mode, in which permission denials are logged but not enforced.\n- *Enforcing* mode, in which permissions denials are both logged **and** enforced.\n\nAndroid includes SELinux in enforcing mode and a corresponding security\npolicy that works by default across AOSP. In enforcing mode, disallowed\nactions are prevented and all attempted violations are logged by the kernel to\n`dmesg` and `logcat`. When developing, you should\nuse these errors to refine your software and SELinux policies before enforcing\nthem. For more details, see [Implementing\nSELinux](/docs/security/features/selinux/implement).\n\nSELinux also supports a *per-domain permissive* mode in which specific\ndomains (processes) can be made permissive while placing the rest of the system\nin global enforcing mode. A domain is simply a label identifying a process or\nset of processes in the security policy, where all processes labeled with the\nsame domain are treated identically by the security policy. Per-domain\npermissive mode enables incremental application of SELinux to an ever-increasing\nportion of the system and policy development for new services (while keeping\nthe rest of the system enforcing).\n\nBackground\n----------\n\nThe Android security model is based in part on the concept of\n[application sandboxes](/docs/security/app-sandbox). Each application\nruns in its own sandbox. Prior to Android 4.3, these sandboxes were defined by\nthe creation of a unique Linux UID for each application at time of installation.\nAndroid 4.3 and later uses SELinux to further define the boundaries of the\nAndroid application sandbox.\n\nIn Android 5.0 and later, SELinux is fully enforced, building on the\npermissive release of Android 4.3 and the partial enforcement of Android 4.4.\nWith this change, Android shifted from enforcement on a limited set of crucial\ndomains (`installd`, `netd`, `vold` and\n`zygote`) to everything (more than 60 domains). Specifically:\n\n- Everything is in enforcing mode in Android 5.x and higher.\n- No processes other than `init` should run in the `init` domain.\n- Any generic denial (for a `block_device`, `socket_device`, `default_service`) indicates that device needs a special domain.\n\nAndroid 6.0 hardened the system by reducing the permissiveness of our\npolicy to include better isolation between users, IOCTL filtering, reduced\nthreat of exposed services, further tightening of SELinux domains, and\nextremely limited `/proc` access.\n\nAndroid 7.0 updated SELinux configuration to further lock down the\napplication sandbox and reduce attack surface. This release also broke up the\nmonolithic mediaserver stack into smaller processes to reduce the scope of\ntheir permissions. For more details, see\n[Protecting\nAndroid with more Linux kernel defenses](https://android-developers.googleblog.com/2016/07/protecting-android-with-more-linux.html) and\n[Hardening the media stack](https://android-developers.googleblog.com/2016/05/hardening-media-stack.html).\n\nAndroid 8.0 updated SELinux to work with [Treble](/docs/core/architecture#hidl), which separates the lower-level\nvendor code from the Android system framework. This release updated SELinux\npolicy to allow device manufacturers and SOC vendors to update their parts of\nthe policy, build their images (`vendor.img`, `boot.img`,\netc.), then update those images independent of the platform or vice versa.\n\nWhile it is possible to have higher/newer platform (framework) version\nrunning on the device, the opposite case is not supported; the vendor images\n(`vendor.img/odm.img`) cannot have a newer version than the platform\n(`system.img`). So, a newer platform version might introduce SELinux\ncompatibility issues because the platform SELinux policy is at a newer version\nthan vendor SELinux parts of the policy. The Android 8.0 model provides a method\nto [retain compatibility](/docs/security/features/selinux/compatibility) to prevent\nunnecessary simultaneous OTAs.\n\nAdditional resources\n--------------------\n\nFor help constructing useful SELinux policies, refer to the following\nresources.\n\n| **Note:** Some SELinux concepts are not used by Android. For further details, see [Specificity](/docs/security/features/selinux/concepts#specificity).\n\n\u003cbr /\u003e\n\n- [The SELinux Notebook](https://github.com/SELinuxProject/selinux-notebook), up-to-date reference for SELinux. This document contains further details on the policy language, the meaning of each of the keywords and how security contexts are computed.\n- [Your visual how-to guide for SELinux policy enforcement](https://opensource.com/business/13/11/selinux-policy-guide)\n- [Security Enhancements for Linux](https://events.static.linuxfound.org/sites/events/files/slides/abs2014_seforandroid_smalley.pdf)\n- [Security Enhanced (SE) Android: Bringing Flexible MAC to Android](http://www.cs.columbia.edu/~lierranli/coms6998-7Spring2014/papers/SEAndroid-NDSS2013.pdf)\n- [Implementing SELinux as a Linux Security Module](https://www.nsa.gov/resources/everyone/digital-media-center/publications/research-papers/assets/files/implementing-selinux-as-linux-security-module-report.pdf)\n- [Configuring the SELinux Policy](https://www.nsa.gov/resources/everyone/digital-media-center/publications/research-papers/assets/files/configuring-selinux-policy-report.pdf)"]]