app.te revision e7ec2f5258550a2cc0cb8c76ef24fc100a6b2cf1
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# Allow apps to connect to the keystore
156634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichunix_socket_connect(appdomain, keystore, keystore)
166634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
176634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Receive and use open file descriptors inherited from zygote.
186634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain zygote:fd use;
196634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
2061dc35072090f2735af2b39572e39eadb30573ebNick Kralevich# Needed to close the zygote socket, which involves getopt / getattr
2161dc35072090f2735af2b39572e39eadb30573ebNick Kralevich# This should be deleted after b/12061011 is fixed
2261dc35072090f2735af2b39572e39eadb30573ebNick Kralevichallow appdomain zygote:unix_stream_socket { getopt getattr };
2361dc35072090f2735af2b39572e39eadb30573ebNick Kralevich
2448759ca2054fa742724cd81debed51208b69e758Stephen Smalley# gdbserver for ndk-gdb reads the zygote.
2548759ca2054fa742724cd81debed51208b69e758Stephen Smalleyallow appdomain zygote_exec:file r_file_perms;
2648759ca2054fa742724cd81debed51208b69e758Stephen Smalley
2748759ca2054fa742724cd81debed51208b69e758Stephen Smalley# gdbserver for ndk-gdb ptrace attaches to app process.
2848759ca2054fa742724cd81debed51208b69e758Stephen Smalleyallow appdomain self:process ptrace;
2948759ca2054fa742724cd81debed51208b69e758Stephen Smalley
306634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Read system properties managed by zygote.
316634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain zygote_tmpfs:file read;
326634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
336634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Notify zygote of death;
346634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain zygote:process sigchld;
356634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
3648759ca2054fa742724cd81debed51208b69e758Stephen Smalley# Notify shell and adbd of death when spawned via runas for ndk-gdb.
3748759ca2054fa742724cd81debed51208b69e758Stephen Smalleyallow appdomain shell:process sigchld;
3848759ca2054fa742724cd81debed51208b69e758Stephen Smalleyallow appdomain adbd:process sigchld;
3948759ca2054fa742724cd81debed51208b69e758Stephen Smalley
4048759ca2054fa742724cd81debed51208b69e758Stephen Smalley# child shell or gdbserver pty access for runas.
4148759ca2054fa742724cd81debed51208b69e758Stephen Smalleyallow appdomain devpts:chr_file { getattr read write ioctl };
4248759ca2054fa742724cd81debed51208b69e758Stephen Smalley
436634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Communicate with system_server.
441fdee11df2552e29da0c48e3432f26f7a93e3bffAlex Klyubinallow appdomain system_server:fifo_file rw_file_perms;
451fdee11df2552e29da0c48e3432f26f7a93e3bffAlex Klyubinallow appdomain system_server:unix_stream_socket { read write setopt };
461fdee11df2552e29da0c48e3432f26f7a93e3bffAlex Klyubinbinder_call(appdomain, system_server)
476634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
4882fc3b524164588388aa3595bd2158020d93d28aNick Kralevich# Communication with other apps via fifos
4982fc3b524164588388aa3595bd2158020d93d28aNick Kralevichallow appdomain appdomain:fifo_file rw_file_perms;
5082fc3b524164588388aa3595bd2158020d93d28aNick Kralevich
516634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Communicate with surfaceflinger.
526634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain surfaceflinger:unix_stream_socket { read write setopt };
536634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichbinder_call(appdomain, surfaceflinger)
546634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
556634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# App sandbox file accesses.
566634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain app_data_file:dir create_dir_perms;
5765317124a0bb7db4829f78e74c7bfe18e27f1c43Stephen Smalleyallow appdomain app_data_file:notdevfile_class_set create_file_perms;
586634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
596634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Read/write data files created by the platform apps if they
606634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# were passed to the app via binder or local IPC.  Do not allow open.
616634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain platform_app_data_file:file { getattr read write };
626634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
636634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# lib subdirectory of /data/data dir is system-owned.
646634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain system_data_file:dir r_dir_perms;
6548759ca2054fa742724cd81debed51208b69e758Stephen Smalleyallow appdomain system_data_file:file { execute execute_no_trans open };
666634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
676634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Execute the shell or other system executables.
686634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain shell_exec:file rx_file_perms;
696634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain system_file:file rx_file_perms;
70cf6b350a32ea65fa359981bd42ca0324547e2784Nick Kralevichallow appdomain ping_exec:file rx_file_perms;
716634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
726634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Read/write wallpaper file (opened by system).
736634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain wallpaper_file:file { read write };
746634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
756634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Write to /data/anr/traces.txt.
766634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain anr_data_file:dir search;
776634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain anr_data_file:file { open append };
786634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
7909e6abd91b3aaaa11a44d032e095360c64a97b3aNick Kralevich# Allow apps to send dump information to dumpstate
8009e6abd91b3aaaa11a44d032e095360c64a97b3aNick Kralevichallow appdomain dumpstate:fd use;
8109e6abd91b3aaaa11a44d032e095360c64a97b3aNick Kralevichallow appdomain dumpstate:unix_stream_socket { read write getopt getattr };
8209e6abd91b3aaaa11a44d032e095360c64a97b3aNick Kralevich
836634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Write to /proc/net/xt_qtaguid/ctrl file.
846634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain qtaguid_proc:file rw_file_perms;
856634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Everybody can read the xt_qtaguid resource tracking misc dev.
866634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# So allow all apps to read from /dev/xt_qtaguid.
876634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain qtaguid_device:chr_file r_file_perms;
886634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
893ba9012535d8412d94db4ae9a5ce928b806e26d8Stephen Smalley# Grant GPU access to all processes started by Zygote.
903ba9012535d8412d94db4ae9a5ce928b806e26d8Stephen Smalley# They need that to render the standard UI.
913ba9012535d8412d94db4ae9a5ce928b806e26d8Stephen Smalleyallow appdomain gpu_device:chr_file { rw_file_perms execute };
923ba9012535d8412d94db4ae9a5ce928b806e26d8Stephen Smalley
936634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Use the Binder.
946634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichbinder_use(appdomain)
956634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Perform binder IPC to binder services.
966634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichbinder_call(appdomain, binderservicedomain)
976634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Perform binder IPC to other apps.
986634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichbinder_call(appdomain, appdomain)
996634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
1006634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Appdomain interaction with isolated apps
1016634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichr_dir_file(appdomain, isolated_app)
1026634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
1036634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Already connected, unnamed sockets being passed over some other IPC
1046634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# hence no sock_file or connectto permission. This appears to be how
1056634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Chrome works, may need to be updated as more apps using isolated services
1066634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# are examined.
1076634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain isolated_app:unix_stream_socket { read write };
1086634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
1096634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Backup ability for every app. BMS opens and passes the fd
1106634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# to any app that has backup ability. Hence, no open permissions here.
11181560733a47633036133ce548bf638bc3d91f5cfGeremy Condraallow appdomain backup_data_file:file { read write getattr };
11281560733a47633036133ce548bf638bc3d91f5cfGeremy Condraallow appdomain cache_backup_file:file { read write getattr };
1136634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Backup ability using 'adb backup'
1146634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain system_data_file:lnk_file getattr;
1156634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
1166634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Allow all applications to read downloaded files
11717454cf805748a8792608a44bbfddb00fb918841Stephen Smalleyallow appdomain download_file:dir search;
1186634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain download_file:file r_file_perms;
1196634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
1206634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Allow applications to communicate with netd via /dev/socket/dnsproxyd
1216634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# to do DNS resolution
1226634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichunix_socket_connect(appdomain, dnsproxyd, netd)
1236634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
1246634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Allow applications to communicate with drmserver over binder
1256634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichbinder_call(appdomain, drmserver)
1266634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
1276634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Allow applications to communicate with mediaserver over binder
1286634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichbinder_call(appdomain, mediaserver)
1296634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
1306634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Allow applications to make outbound tcp connections to any port
1316634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain port_type:tcp_socket name_connect;
1326634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
1336634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Allow apps to see changes to the routing table.
1346634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain self:netlink_route_socket {
1356634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich    read
1366634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich    bind
1376634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich    create
1386634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich    nlmsg_read
1396634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich    ioctl
1406634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich    getattr
1416634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich    setattr
1426634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich    getopt
1436634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich    setopt
1446634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich    shutdown
1456634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich};
1466634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
1476634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Allow apps to use rawip sockets. This is needed for apps which execute
1486634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# /system/bin/ping, for example.
1496634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichallow appdomain self:rawip_socket create_socket_perms;
1506634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
1510b8c20e7ddce7cf791447f15be540ee2d0a6bfb2Nick Kralevich# Allow apps to use the USB Accessory interface.
1520b8c20e7ddce7cf791447f15be540ee2d0a6bfb2Nick Kralevich# http://developer.android.com/guide/topics/connectivity/usb/accessory.html
1530b8c20e7ddce7cf791447f15be540ee2d0a6bfb2Nick Kralevich#
1540b8c20e7ddce7cf791447f15be540ee2d0a6bfb2Nick Kralevich# USB devices are first opened by the system server (USBDeviceManagerService)
1550b8c20e7ddce7cf791447f15be540ee2d0a6bfb2Nick Kralevich# and the file descriptor is passed to the right Activity via binder.
1560b8c20e7ddce7cf791447f15be540ee2d0a6bfb2Nick Kralevichallow appdomain usb_device:chr_file { read write getattr ioctl };
1570b8c20e7ddce7cf791447f15be540ee2d0a6bfb2Nick Kralevichallow appdomain usbaccessory_device:chr_file { read write getattr };
1580b8c20e7ddce7cf791447f15be540ee2d0a6bfb2Nick Kralevich
159527316a21b80c2a70d8ed23351299a4dce0c77bfStephen Smalley# For art.
160527316a21b80c2a70d8ed23351299a4dce0c77bfStephen Smalleyallow appdomain dalvikcache_data_file:file execute;
161527316a21b80c2a70d8ed23351299a4dce0c77bfStephen Smalley
1626634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich###
163594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley### CTS-specific rules
164594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley###
165594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley
166594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley# For cts/tools/device-setup/TestDeviceSetup/src/android/tests/getinfo/RootProcessScanner.java.
167594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley# Reads /proc/pid/status and statm entries to check that
168594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley# no unexpected root processes are running.
169594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley# Also for cts/tests/tests/security/src/android/security/cts/VoldExploitTest.java
170594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley# Reads /proc/pid/cmdline of vold.
171594693705f0d5768db3c3212037da5fd5d5653beStephen Smalleyallow appdomain domain:dir { open read search getattr };
172594693705f0d5768db3c3212037da5fd5d5653beStephen Smalleyallow appdomain domain:{ file lnk_file } { open read getattr };
173594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley
174594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley# For cts/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java.
175594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley# testRunAsHasCorrectCapabilities
176594693705f0d5768db3c3212037da5fd5d5653beStephen Smalleyallow appdomain runas_exec:file getattr;
177594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley# Others are either allowed elsewhere or not desired.
178594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley
179594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley# For cts/tests/tests/security/src/android/security/cts/SELinuxTest.java
180594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley# Check SELinux policy and contexts.
181594693705f0d5768db3c3212037da5fd5d5653beStephen Smalleyselinux_check_access(appdomain)
182594693705f0d5768db3c3212037da5fd5d5653beStephen Smalleyselinux_check_context(appdomain)
183594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley# Validate that each process is running in the correct security context.
184594693705f0d5768db3c3212037da5fd5d5653beStephen Smalleyallow appdomain domain:process getattr;
185594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley
186594693705f0d5768db3c3212037da5fd5d5653beStephen Smalley###
1876634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich### Neverallow rules
1886634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich###
1896634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich### These are things that Android apps should NEVER be able to do
1906634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich###
1916634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
1926634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Superuser capabilities.
1932a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# bluetooth requires net_admin.
1942a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain -bluetooth } self:capability *;
1956634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichneverallow { appdomain -unconfineddomain } self:capability2 *;
1966634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
1976634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Block device access.
1986634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichneverallow { appdomain -unconfineddomain } dev_type:blk_file { read write };
1996634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
2002a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Access to any character device that is not specifically typed.
2012a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } device:chr_file { read write };
2022a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
2032a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Access to any of the following character devices.
2042a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } {
2052a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    audio_device
2062a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    camera_device
2072a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    dm_device
2082a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    radio_device
2092a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    gps_device
2102a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    rpmsg_device
2112a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley}:chr_file { read write };
2122a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
2132a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Note: Try expanding list of app domains in the future.
2142a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { untrusted_app isolated_app shell -unconfineddomain }
2152a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    graphics_device:chr_file { read write };
2162a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
2172a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -nfc -unconfineddomain } nfc_device:chr_file
2182a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { read write };
2192a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -bluetooth -unconfineddomain } hci_attach_dev:chr_file
2202a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { read write };
2212a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } tee_device:chr_file { read write };
2222a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
2232a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Set SELinux enforcing mode, booleans or any other SELinux settings.
2242a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } kernel:security
2252a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { setenforce setbool setsecparam setcheckreqprot };
2266634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
2276634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Load security policy.
2282637198f92d5d9c65262e42d78123d216889d546Nick Kralevichneverallow appdomain kernel:security load_policy;
2296634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
2306634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Privileged netlink socket interfaces.
2316634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichneverallow { appdomain -unconfineddomain }
2326634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich    self:{
2336634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich        netlink_socket
2346634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich        netlink_firewall_socket
2356634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich        netlink_tcpdiag_socket
2366634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich        netlink_nflog_socket
2376634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich        netlink_xfrm_socket
2386634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich        netlink_audit_socket
2396634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich        netlink_ip6fw_socket
2406634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich        netlink_dnrt_socket
2416634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich        netlink_kobject_uevent_socket
2426634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich    } *;
2436634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
2442a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Sockets under /dev/socket that are not specifically typed.
2452a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } socket_device:sock_file write;
2462a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
2472a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Unix domain sockets.
2482a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } adbd_socket:sock_file write;
2492a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } bluetooth_socket:sock_file write;
2502a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } installd_socket:sock_file write;
2512a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -bluetooth -radio -shell -system_app -unconfineddomain }
2522a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    property_socket:sock_file write;
2532a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -radio -unconfineddomain } rild_socket:sock_file write;
2542a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } vold_socket:sock_file write;
2552a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } zygote_socket:sock_file write;
2562a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
2576634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# ptrace access to non-app domains.
2586634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevichneverallow { appdomain -unconfineddomain } { domain -appdomain }:process ptrace;
2596634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
2602a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Write access to /proc/pid entries for any non-app domain.
26173c5ea722c7ee328f0d10179601afd9d5a054b94Nick Kralevichneverallow { appdomain -unconfineddomain } { domain -appdomain }:file write;
2622a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
2632a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# signal access to non-app domains.
2642a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# sigchld allowed for parent death notification.
2652a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# signull allowed for kill(pid, 0) existence test.
2662a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# All others prohibited.
2672a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } { domain -appdomain }:process
2682a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { sigkill sigstop signal };
2692a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
2706634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Transition to a non-app domain.
27157085446eb49777189123a994884f76b8491ed26Stephen Smalley# Exception for the shell domain, can transition to runas, ping, etc.
27257085446eb49777189123a994884f76b8491ed26Stephen Smalleyneverallow { appdomain -shell -unconfineddomain } ~appdomain:process
2732a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { transition dyntransition };
2742a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
2752a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Map low memory.
2762a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Note: Take to domain.te and apply to all domains in the future.
2772a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } self:memprotect mmap_zero;
2782a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
2792a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Write to rootfs.
2802a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } rootfs:dir_file_class_set
2812a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
2826634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
2836634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Write to /system.
2842a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } system_file:dir_file_class_set
2852a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
2862a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
2872a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Write to entrypoint executables.
2882a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } exec_type:file
2892a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
2906634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich
2916634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Write to system-owned parts of /data.
2926634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# This is the default type for anything under /data not otherwise
2936634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# specified in file_contexts.  Define a different type for portions
2946634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# that should be writable by apps.
2956634a1080e6617854d0b29bc65bb1c852ad3d5b6Nick Kralevich# Exception for system_app for Settings.
2962a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain -system_app }
2972a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    system_data_file:dir_file_class_set
2982a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
2992a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
3002a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Write to various other parts of /data.
3012a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -system_app -unconfineddomain }
3022a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    security_file:dir_file_class_set
3032a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
3042a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } drm_data_file:dir_file_class_set
3052a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
3062a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } gps_data_file:dir_file_class_set
3072a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
3082a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -platform_app -unconfineddomain }
3092a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    apk_data_file:dir_file_class_set
3102a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
3112a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -platform_app -unconfineddomain }
3122a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    apk_tmp_file:dir_file_class_set
3132a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
3142a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -platform_app -unconfineddomain }
3152a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    apk_private_data_file:dir_file_class_set
3162a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
3172a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -platform_app -unconfineddomain }
3182a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    apk_private_tmp_file:dir_file_class_set
3192a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
3202a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -shell -unconfineddomain }
3212a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    shell_data_file:dir_file_class_set
3222a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
3232a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -bluetooth -unconfineddomain }
3242a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    bluetooth_data_file:dir_file_class_set
3252a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
3262a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain }
3272a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    keystore_data_file:dir_file_class_set
3282a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
3292a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain }
3302a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    systemkeys_data_file:dir_file_class_set
3312a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
3322a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain }
3332a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    wifi_data_file:dir_file_class_set
3342a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
3352a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain }
3362a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    dhcp_data_file:dir_file_class_set
3372a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    { create write setattr relabelfrom relabelto append unlink link rename };
3382a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
3392a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Access to factory files.
3402a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain }
3412a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    efs_file:dir_file_class_set { read write };
3422a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
3432a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Write to various pseudo file systems.
3442a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -nfc -unconfineddomain }
3452a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    sysfs:dir_file_class_set write;
3462a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain }
3472a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    proc:dir_file_class_set write;
3482a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
3492a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Access to syslog(2) or /proc/kmsg.
3502a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -system_app -unconfineddomain }
3512a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    kernel:system { syslog_read syslog_mod syslog_console };
3522a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
3532a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Ability to perform any filesystem operation other than statfs(2).
3542a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# i.e. no mount(2), unmount(2), etc.
3552a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -unconfineddomain } fs_type:filesystem ~getattr;
3562a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley
3572a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley# Ability to set system properties.
3582a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalleyneverallow { appdomain -system_app -radio -shell -bluetooth -unconfineddomain }
3592a273ad2c50b255985a71e92898ac9224a9d2bd7Stephen Smalley    property_type:property_service set;
360