app.te revision 91a4f8d4fdab7df8474c2ffaa996c879166d8a4c
1748fdef626d1dda2a0a727ea35d85d04363f5307Nick Kralevich###
2748fdef626d1dda2a0a727ea35d85d04363f5307Nick Kralevich### Domain for all zygote spawned apps
3748fdef626d1dda2a0a727ea35d85d04363f5307Nick Kralevich###
4748fdef626d1dda2a0a727ea35d85d04363f5307Nick Kralevich### This file is the base policy for all zygote spawned apps.
5748fdef626d1dda2a0a727ea35d85d04363f5307Nick Kralevich### Other policy files, such as isolated_app.te, untrusted_app.te, etc
6748fdef626d1dda2a0a727ea35d85d04363f5307Nick Kralevich### extend from this policy. Only policies which should apply to ALL
7748fdef626d1dda2a0a727ea35d85d04363f5307Nick Kralevich### zygote spawned apps should be added here.
8748fdef626d1dda2a0a727ea35d85d04363f5307Nick Kralevich###
9748fdef626d1dda2a0a727ea35d85d04363f5307Nick Kralevich
10ad7df7bb76ce00cdef711ad1f96a9a7243981f4eStephen Smalley# Dalvik Compiler JIT Mapping.
11ad7df7bb76ce00cdef711ad1f96a9a7243981f4eStephen Smalleyallow appdomain self:process execmem;
12e7ec2f5258550a2cc0cb8c76ef24fc100a6b2cf1Stephen Smalleyallow appdomain ashmem_device:chr_file execute;
13ad7df7bb76ce00cdef711ad1f96a9a7243981f4eStephen Smalley
146634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Receive and use open file descriptors inherited from zygote.
156634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain zygote:fd use;
166634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
1748759ca2054fa742724cd81debed51208b69e758Stephen Smalley# gdbserver for ndk-gdb reads the zygote.
1848759ca2054fa742724cd81debed51208b69e758Stephen Smalleyallow appdomain zygote_exec:file r_file_perms;
1948759ca2054fa742724cd81debed51208b69e758Stephen Smalley
2048759ca2054fa742724cd81debed51208b69e758Stephen Smalley# gdbserver for ndk-gdb ptrace attaches to app process.
2148759ca2054fa742724cd81debed51208b69e758Stephen Smalleyallow appdomain self:process ptrace;
2248759ca2054fa742724cd81debed51208b69e758Stephen Smalley
236634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Read system properties managed by zygote.
246634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain zygote_tmpfs:file read;
256634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
266634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Notify zygote of death;
276634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain zygote:process sigchld;
286634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
2948759ca2054fa742724cd81debed51208b69e758Stephen Smalley# Notify shell and adbd of death when spawned via runas for ndk-gdb.
3048759ca2054fa742724cd81debed51208b69e758Stephen Smalleyallow appdomain shell:process sigchld;
3148759ca2054fa742724cd81debed51208b69e758Stephen Smalleyallow appdomain adbd:process sigchld;
3248759ca2054fa742724cd81debed51208b69e758Stephen Smalley
3348759ca2054fa742724cd81debed51208b69e758Stephen Smalley# child shell or gdbserver pty access for runas.
3448759ca2054fa742724cd81debed51208b69e758Stephen Smalleyallow appdomain devpts:chr_file { getattr read write ioctl };
3548759ca2054fa742724cd81debed51208b69e758Stephen Smalley
363dad7b611a448fa43a678ff760c23a00f387947eStephen Smalley# Use pipes and sockets provided by system_server via binder or local socket.
371fdee11df2552e29da0c48e3432f26f7a93e3bffAlex Klyubinallow appdomain system_server:fifo_file rw_file_perms;
383dad7b611a448fa43a678ff760c23a00f387947eStephen Smalleyallow appdomain system_server:unix_stream_socket { read write setopt getattr getopt shutdown };
393dad7b611a448fa43a678ff760c23a00f387947eStephen Smalleyallow appdomain system_server:tcp_socket { read write getattr getopt shutdown };
406634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
4182fc3b524164588388aa3595bd2158020d93d28aNick Kralevich# Communication with other apps via fifos
4282fc3b524164588388aa3595bd2158020d93d28aNick Kralevichallow appdomain appdomain:fifo_file rw_file_perms;
4382fc3b524164588388aa3595bd2158020d93d28aNick Kralevich
446634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Communicate with surfaceflinger.
45b0db712bf048dc634363b658a647b1f1897d8433Stephen Smalleyallow appdomain surfaceflinger:unix_stream_socket { read write setopt getattr getopt shutdown };
466634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
476634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# App sandbox file accesses.
486634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain app_data_file:dir create_dir_perms;
4965317124a0bb7db4829f78e74c7bfe18e27f1c43Stephen Smalleyallow appdomain app_data_file:notdevfile_class_set create_file_perms;
506634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
516634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# lib subdirectory of /data/data dir is system-owned.
526634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain system_data_file:dir r_dir_perms;
5348759ca2054fa742724cd81debed51208b69e758Stephen Smalleyallow appdomain system_data_file:file { execute execute_no_trans open };
546634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
556736bac21870bdc8bb6098ddffdb70103f7bc2a3Jeff Sharkey# Access to OEM provided data and apps
566736bac21870bdc8bb6098ddffdb70103f7bc2a3Jeff Sharkeyallow appdomain oemfs:dir r_dir_perms;
576736bac21870bdc8bb6098ddffdb70103f7bc2a3Jeff Sharkeyallow appdomain oemfs:file rx_file_perms;
586736bac21870bdc8bb6098ddffdb70103f7bc2a3Jeff Sharkey
596634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Execute the shell or other system executables.
606634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain shell_exec:file rx_file_perms;
616634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain system_file:file rx_file_perms;
626634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
636634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Read/write wallpaper file (opened by system).
64fc4c6b798a0c8ff38b4b943209ba1653a0276dfaRobert Craigallow appdomain wallpaper_file:file { getattr read write };
656634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
666634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Write to /data/anr/traces.txt.
676634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain anr_data_file:dir search;
686634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain anr_data_file:file { open append };
696634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
7009e6abd91b3aaaa11a44d032e095360c64a97b3aNick Kralevich# Allow apps to send dump information to dumpstate
7109e6abd91b3aaaa11a44d032e095360c64a97b3aNick Kralevichallow appdomain dumpstate:fd use;
72b0db712bf048dc634363b658a647b1f1897d8433Stephen Smalleyallow appdomain dumpstate:unix_stream_socket { read write getopt getattr shutdown };
732e7a301fad5b6065e2d364170a80bc58bc41aab0Nick Kralevichallow appdomain shell_data_file:file { write getattr };
7409e6abd91b3aaaa11a44d032e095360c64a97b3aNick Kralevich
756634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Write to /proc/net/xt_qtaguid/ctrl file.
766634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain qtaguid_proc:file rw_file_perms;
776634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Everybody can read the xt_qtaguid resource tracking misc dev.
786634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# So allow all apps to read from /dev/xt_qtaguid.
796634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain qtaguid_device:chr_file r_file_perms;
806634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
813ba9012535d8412d94db4ae9a5ce928b806e26d8Stephen Smalley# Grant GPU access to all processes started by Zygote.
823ba9012535d8412d94db4ae9a5ce928b806e26d8Stephen Smalley# They need that to render the standard UI.
833ba9012535d8412d94db4ae9a5ce928b806e26d8Stephen Smalleyallow appdomain gpu_device:chr_file { rw_file_perms execute };
843ba9012535d8412d94db4ae9a5ce928b806e26d8Stephen Smalley
856634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Use the Binder.
866634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichbinder_use(appdomain)
876634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Perform binder IPC to binder services.
886634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichbinder_call(appdomain, binderservicedomain)
896634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Perform binder IPC to other apps.
906634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichbinder_call(appdomain, appdomain)
916634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
926634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Already connected, unnamed sockets being passed over some other IPC
936634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# hence no sock_file or connectto permission. This appears to be how
946634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Chrome works, may need to be updated as more apps using isolated services
956634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# are examined.
96b0db712bf048dc634363b658a647b1f1897d8433Stephen Smalleyallow appdomain appdomain:unix_stream_socket { getopt getattr read write shutdown };
976634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
986634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Backup ability for every app. BMS opens and passes the fd
996634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# to any app that has backup ability. Hence, no open permissions here.
10081560733a47633036133ce548bf638bc3d91f5cfGeremy Condraallow appdomain backup_data_file:file { read write getattr };
10181560733a47633036133ce548bf638bc3d91f5cfGeremy Condraallow appdomain cache_backup_file:file { read write getattr };
1029ba844fea12a0b08770e870d63f3d3c375c7c9b5Stephen Smalleyallow appdomain cache_backup_file:dir getattr;
1036634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Backup ability using 'adb backup'
1046634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain system_data_file:lnk_file getattr;
1056634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
1062737ceff233a32be67ebc6e3dba6e80b8df6df0aStephen Smalley# Allow read/stat of /data/media files passed by Binder or local socket IPC.
1072737ceff233a32be67ebc6e3dba6e80b8df6df0aStephen Smalleyallow appdomain media_rw_data_file:file { read getattr };
1082737ceff233a32be67ebc6e3dba6e80b8df6df0aStephen Smalley
1091545b6061518bac473cf93af576cbea12a992298Nick Kralevich# Read and write /data/data/com.android.providers.telephony files passed over Binder.
1101545b6061518bac473cf93af576cbea12a992298Nick Kralevichallow appdomain radio_data_file:file { read write getattr };
1113fbc536dfd5afbce5ef45f18d0afb3516089ed88Stephen Smalley
11291a4f8d4fdab7df8474c2ffaa996c879166d8a4cStephen Smalley# Read and write system app data files passed over Binder.
11391a4f8d4fdab7df8474c2ffaa996c879166d8a4cStephen Smalley# Motivating case was /data/data/com.android.settings/cache/*.jpg for
11491a4f8d4fdab7df8474c2ffaa996c879166d8a4cStephen Smalley# cropping or taking user photos.
11591a4f8d4fdab7df8474c2ffaa996c879166d8a4cStephen Smalleyallow untrusted_app system_app_data_file:file { read write getattr };
11691a4f8d4fdab7df8474c2ffaa996c879166d8a4cStephen Smalley
117b0db712bf048dc634363b658a647b1f1897d8433Stephen Smalley# Access SDcard.
118b0db712bf048dc634363b658a647b1f1897d8433Stephen Smalleyallow appdomain sdcard_type:dir create_dir_perms;
119b0db712bf048dc634363b658a647b1f1897d8433Stephen Smalleyallow appdomain sdcard_type:file create_file_perms;
120b0db712bf048dc634363b658a647b1f1897d8433Stephen Smalley
1210b8c20e7ddce7cf791447f15be540ee2d0a6bfb2Nick Kralevich# Allow apps to use the USB Accessory interface.
1220b8c20e7ddce7cf791447f15be540ee2d0a6bfb2Nick Kralevich# http://developer.android.com/guide/topics/connectivity/usb/accessory.html
1230b8c20e7ddce7cf791447f15be540ee2d0a6bfb2Nick Kralevich#
1240b8c20e7ddce7cf791447f15be540ee2d0a6bfb2Nick Kralevich# USB devices are first opened by the system server (USBDeviceManagerService)
1250b8c20e7ddce7cf791447f15be540ee2d0a6bfb2Nick Kralevich# and the file descriptor is passed to the right Activity via binder.
1260b8c20e7ddce7cf791447f15be540ee2d0a6bfb2Nick Kralevichallow appdomain usb_device:chr_file { read write getattr ioctl };
1270b8c20e7ddce7cf791447f15be540ee2d0a6bfb2Nick Kralevichallow appdomain usbaccessory_device:chr_file { read write getattr };
1280b8c20e7ddce7cf791447f15be540ee2d0a6bfb2Nick Kralevich
129527316a21b80c2a70d8ed23351299a4dce0c77bfStephen Smalley# For art.
130527316a21b80c2a70d8ed23351299a4dce0c77bfStephen Smalleyallow appdomain dalvikcache_data_file:file execute;
131527316a21b80c2a70d8ed23351299a4dce0c77bfStephen Smalley
13219c509034ee309c60c958637841c151d3c273421Stephen Smalley# /data/dalvik-cache/profiles
13319c509034ee309c60c958637841c151d3c273421Stephen Smalleyallow appdomain dalvikcache_profiles_data_file:file write;
13419c509034ee309c60c958637841c151d3c273421Stephen Smalley
135959fdaaa25d7dbfad8a1900dfe9575f873cea649Stephen Smalley# For legacy unlabeled userdata on existing devices.
136959fdaaa25d7dbfad8a1900dfe9575f873cea649Stephen Smalley# See discussion of Unlabeled files in domain.te for more information.
137959fdaaa25d7dbfad8a1900dfe9575f873cea649Stephen Smalleyallow appdomain unlabeled:file x_file_perms;
1382562843425bb5f13e42b8605a1568308c6faff71Stephen Smalleyauditallow appdomain unlabeled:file x_file_perms;
139959fdaaa25d7dbfad8a1900dfe9575f873cea649Stephen Smalley
1406634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich###
141594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley### CTS-specific rules
142594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley###
143594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley
144594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley# For cts/tools/device-setup/TestDeviceSetup/src/android/tests/getinfo/RootProcessScanner.java.
145594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley# Reads /proc/pid/status and statm entries to check that
146594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley# no unexpected root processes are running.
147594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley# Also for cts/tests/tests/security/src/android/security/cts/VoldExploitTest.java
148594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley# Reads /proc/pid/cmdline of vold.
149594693705f0d5768db3c3212037da5fd5d5653beStephen Smalleyallow appdomain domain:dir { open read search getattr };
150594693705f0d5768db3c3212037da5fd5d5653beStephen Smalleyallow appdomain domain:{ file lnk_file } { open read getattr };
151594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley
152594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley# For cts/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java.
153594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley# testRunAsHasCorrectCapabilities
154594693705f0d5768db3c3212037da5fd5d5653beStephen Smalleyallow appdomain runas_exec:file getattr;
155594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley# Others are either allowed elsewhere or not desired.
156594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley
157594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley# For cts/tests/tests/security/src/android/security/cts/SELinuxTest.java
158594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley# Check SELinux policy and contexts.
159594693705f0d5768db3c3212037da5fd5d5653beStephen Smalleyselinux_check_access(appdomain)
160594693705f0d5768db3c3212037da5fd5d5653beStephen Smalleyselinux_check_context(appdomain)
161594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley# Validate that each process is running in the correct security context.
162594693705f0d5768db3c3212037da5fd5d5653beStephen Smalleyallow appdomain domain:process getattr;
163594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley
1648ed750e9731e6e3a21785e91e9b1cf7390c16738Mark Salyzyn# logd access
1658ed750e9731e6e3a21785e91e9b1cf7390c16738Mark Salyzynread_logd(appdomain)
1668ed750e9731e6e3a21785e91e9b1cf7390c16738Mark Salyzyn# application inherit logd write socket (urge is to deprecate this long term)
1678ed750e9731e6e3a21785e91e9b1cf7390c16738Mark Salyzynallow appdomain zygote:unix_dgram_socket write;
1688ed750e9731e6e3a21785e91e9b1cf7390c16738Mark Salyzyn
169594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley###
1706634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich### Neverallow rules
1716634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich###
1726634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich### These are things that Android apps should NEVER be able to do
1736634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich###
1746634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
1756634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Superuser capabilities.
1762a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# bluetooth requires net_admin.
1772a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain -bluetooth } self:capability *;
1786634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichneverallow { appdomain -unconfineddomain } self:capability2 *;
1796634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
1806634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Block device access.
1816634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichneverallow { appdomain -unconfineddomain } dev_type:blk_file { read write };
1826634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
1832a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Access to any of the following character devices.
1842a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } {
1852a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    audio_device
1862a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    camera_device
1872a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    dm_device
1882a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    radio_device
1892a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    gps_device
1902a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    rpmsg_device
1912a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley}:chr_file { read write };
1922a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
1932a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Note: Try expanding list of app domains in the future.
1942a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { untrusted_app isolated_app shell -unconfineddomain }
1952a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    graphics_device:chr_file { read write };
1962a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
1972a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -nfc -unconfineddomain } nfc_device:chr_file
1982a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { read write };
1992a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -bluetooth -unconfineddomain } hci_attach_dev:chr_file
2002a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { read write };
2012a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } tee_device:chr_file { read write };
2022a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
2036634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Privileged netlink socket interfaces.
2046634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichneverallow { appdomain -unconfineddomain }
2056634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich    self:{
2066634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich        netlink_socket
2076634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich        netlink_firewall_socket
2086634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich        netlink_tcpdiag_socket
2096634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich        netlink_nflog_socket
2106634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich        netlink_xfrm_socket
2116634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich        netlink_audit_socket
2126634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich        netlink_ip6fw_socket
2136634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich        netlink_dnrt_socket
2146634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich        netlink_kobject_uevent_socket
2156634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich    } *;
2166634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
2172a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Sockets under /dev/socket that are not specifically typed.
2182a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } socket_device:sock_file write;
2192a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
2202a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Unix domain sockets.
2212a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } adbd_socket:sock_file write;
2222a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } installd_socket:sock_file write;
2232a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -bluetooth -radio -shell -system_app -unconfineddomain }
2242a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    property_socket:sock_file write;
2252a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -radio -unconfineddomain } rild_socket:sock_file write;
2262a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } vold_socket:sock_file write;
2272a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } zygote_socket:sock_file write;
2282a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
2296634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# ptrace access to non-app domains.
2306634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichneverallow { appdomain -unconfineddomain } { domain -appdomain }:process ptrace;
2316634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
2322a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Write access to /proc/pid entries for any non-app domain.
23373c5ea722c7ee328f0d10179601afd9d5a054b94Nick Kralevichneverallow { appdomain -unconfineddomain } { domain -appdomain }:file write;
2342a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
2352a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# signal access to non-app domains.
2362a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# sigchld allowed for parent death notification.
2372a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# signull allowed for kill(pid, 0) existence test.
2382a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# All others prohibited.
2392a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } { domain -appdomain }:process
2402a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { sigkill sigstop signal };
2412a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
2426634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Transition to a non-app domain.
243396015c3952bcbd5678dc20d5e5e4407cf6a4d4aStephen Smalley# Exception for the shell domain, can transition to runas, etc.
24457085446eb49777189123a994884f76b8491ed26Stephen Smalleyneverallow { appdomain -shell -unconfineddomain } ~appdomain:process
2452a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { transition dyntransition };
2462a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
2472a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Map low memory.
2482a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Note: Take to domain.te and apply to all domains in the future.
2492a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } self:memprotect mmap_zero;
2502a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
2512a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Write to rootfs.
2522a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } rootfs:dir_file_class_set
2532a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
2546634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
2556634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Write to /system.
2562a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } system_file:dir_file_class_set
2572a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
2582a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
2592a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Write to entrypoint executables.
2602a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } exec_type:file
2612a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
2626634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
2636634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Write to system-owned parts of /data.
2646634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# This is the default type for anything under /data not otherwise
2656634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# specified in file_contexts.  Define a different type for portions
2666634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# that should be writable by apps.
2676634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Exception for system_app for Settings.
2682a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain -system_app }
2692a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    system_data_file:dir_file_class_set
2702a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
2712a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
2722a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Write to various other parts of /data.
2732a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -system_app -unconfineddomain }
2742a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    security_file:dir_file_class_set
2752a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
2762a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } drm_data_file:dir_file_class_set
2772a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
2782a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } gps_data_file:dir_file_class_set
2792a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
2802a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -platform_app -unconfineddomain }
2812a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    apk_data_file:dir_file_class_set
2822a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
2832a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -platform_app -unconfineddomain }
2842a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    apk_tmp_file:dir_file_class_set
2852a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
2862a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -platform_app -unconfineddomain }
2872a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    apk_private_data_file:dir_file_class_set
2882a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
2892a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -platform_app -unconfineddomain }
2902a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    apk_private_tmp_file:dir_file_class_set
2912a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
2922a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -shell -unconfineddomain }
2932a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    shell_data_file:dir_file_class_set
2942e7a301fad5b6065e2d364170a80bc58bc41aab0Nick Kralevich    { create setattr relabelfrom relabelto append unlink link rename };
2952a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -bluetooth -unconfineddomain }
2962a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    bluetooth_data_file:dir_file_class_set
2972a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
2982a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain }
2992a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    keystore_data_file:dir_file_class_set
3002a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
3012a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain }
3022a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    systemkeys_data_file:dir_file_class_set
3032a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
3042a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain }
3052a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    wifi_data_file:dir_file_class_set
3062a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
3072a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain }
3082a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    dhcp_data_file:dir_file_class_set
3092a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
3102a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
3112a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Access to factory files.
3122a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain }
3132a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    efs_file:dir_file_class_set { read write };
3142a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
3152a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Write to various pseudo file systems.
316df8af76f2678e3ea63e83701ac4b5afec24adf9fStephen Smalleyneverallow { appdomain -bluetooth -nfc -unconfineddomain }
3172a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    sysfs:dir_file_class_set write;
3182a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain }
3192a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    proc:dir_file_class_set write;
3202a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
3212a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Access to syslog(2) or /proc/kmsg.
3222a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -system_app -unconfineddomain }
3232a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    kernel:system { syslog_read syslog_mod syslog_console };
3242a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
3252a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Ability to perform any filesystem operation other than statfs(2).
3262a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# i.e. no mount(2), unmount(2), etc.
3272a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } fs_type:filesystem ~getattr;
3282a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
3292a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Ability to set system properties.
3302a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -system_app -radio -shell -bluetooth -unconfineddomain }
3312a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    property_type:property_service set;
332