Skip to content

Commit d135986

Browse files
renlordrandomhydrosol
authored andcommitted
split out untrusted base app domains
Signed-off-by: anupritaisno1 <[email protected]> Change-Id: I107b8365c938f03b7d98fefa01763cee6732eb57
1 parent 471e493 commit d135986

31 files changed

+496
-14
lines changed

prebuilts/api/30.0/private/app_neverallows.te

+18-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ define(`all_untrusted_apps',`{
1212
untrusted_app_27
1313
untrusted_app_29
1414
untrusted_app_all
15+
untrusted_base_app
16+
untrusted_base_app_25
17+
untrusted_base_app_27
18+
untrusted_base_app_29
1519
}')
1620
# Receive or send uevent messages.
1721
neverallow all_untrusted_apps domain:netlink_kobject_uevent_socket *;
@@ -55,7 +59,9 @@ neverallow all_untrusted_apps app_exec_data_file:file
5559
neverallow {
5660
all_untrusted_apps
5761
-untrusted_app_25
62+
-untrusted_base_app_25
5863
-untrusted_app_27
64+
-untrusted_base_app_27
5965
-runas_app
6066
} { app_data_file privapp_data_file }:file execute_no_trans;
6167

@@ -65,7 +71,9 @@ neverallow {
6571
neverallow {
6672
all_untrusted_apps
6773
-untrusted_app_25
74+
-untrusted_base_app_25
6875
-untrusted_app_27
76+
-untrusted_base_app_27
6977
} dex2oat_exec:file no_x_file_perms;
7078

7179
# Do not allow untrusted apps to be assigned mlstrustedsubject.
@@ -117,8 +125,11 @@ neverallow all_untrusted_apps *:{
117125
neverallow {
118126
all_untrusted_apps
119127
-untrusted_app_25
128+
-untrusted_base_app_25
120129
-untrusted_app_27
130+
-untrusted_base_app_27
121131
-untrusted_app_29
132+
-untrusted_base_app_29
122133
} domain:netlink_route_socket { bind nlmsg_readpriv };
123134

124135
# Do not allow untrusted apps access to /cache
@@ -244,7 +255,11 @@ neverallow all_untrusted_apps selinuxfs:file no_rw_file_perms;
244255
# b/33214085 b/33814662 b/33791054 b/33211769
245256
# https://github.com/strazzere/anti-emulator/blob/master/AntiEmulator/src/diff/strazzere/anti/emulator/FindEmulator.java
246257
# This will go away in a future Android release
247-
neverallow { all_untrusted_apps -untrusted_app_25 } proc_tty_drivers:file r_file_perms;
258+
neverallow {
259+
all_untrusted_apps
260+
-untrusted_app_25
261+
-untrusted_base_app_25
262+
} proc_tty_drivers:file r_file_perms;
248263
neverallow all_untrusted_apps proc_tty_drivers:file ~r_file_perms;
249264

250265
# Untrusted apps are not allowed to use cgroups.
@@ -255,7 +270,9 @@ neverallow all_untrusted_apps cgroup:file *;
255270
neverallow {
256271
all_untrusted_apps
257272
-untrusted_app_25
273+
-untrusted_base_app_25
258274
-untrusted_app_27
275+
-untrusted_base_app_27
259276
} mnt_sdcard_file:lnk_file *;
260277

261278
# Only privileged apps may find the incident service

prebuilts/api/30.0/private/compat/26.0/26.0.ignore.cil

+4
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@
193193
traced_probes_tmpfs
194194
traced_producer_socket
195195
traced_tmpfs
196+
untrusted_base_app
197+
untrusted_base_app_25
198+
untrusted_base_app_27
199+
untrusted_base_app_29
196200
untrusted_app_all_devpts
197201
update_engine_log_data_file
198202
vendor_default_prop

prebuilts/api/30.0/private/compat/27.0/27.0.ignore.cil

+4
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@
172172
traceur_app
173173
traceur_app_tmpfs
174174
untrusted_app_all_devpts
175+
untrusted_base_app
176+
untrusted_base_app_25
177+
untrusted_base_app_27
178+
untrusted_base_app_29
175179
update_engine_log_data_file
176180
uri_grants_service
177181
usbd

prebuilts/api/30.0/private/compat/28.0/28.0.ignore.cil

+4
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@
148148
traced_lazy_prop
149149
uri_grants_service
150150
use_memfd_prop
151+
untrusted_base_app
152+
untrusted_base_app_25
153+
untrusted_base_app_27
154+
untrusted_base_app_29
151155
vendor_apex_file
152156
vendor_cgroup_desc_file
153157
vendor_idc_file

prebuilts/api/30.0/private/compat/29.0/29.0.ignore.cil

+4
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@
123123
userspace_reboot_test_prop
124124
vehicle_hal_prop
125125
tv_tuner_resource_mgr_service
126+
untrusted_base_app
127+
untrusted_base_app_25
128+
untrusted_base_app_27
129+
untrusted_base_app_29
126130
vendor_apex_file
127131
vendor_boringssl_self_test
128132
vendor_install_recovery

prebuilts/api/30.0/private/seapp_contexts

+5-5
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,15 @@ user=_app isPrivApp=true name=com.google.android.providers.media.module domain=m
170170
user=_app seinfo=platform isPrivApp=true name=com.android.permissioncontroller domain=permissioncontroller_app type=privapp_data_file levelFrom=all
171171
user=_app seinfo=base isPrivApp=true name=com.android.vzwomatrigger domain=vzwomatrigger_app type=privapp_data_file levelFrom=all
172172
user=_app isPrivApp=true name=com.android.vzwomatrigger domain=vzwomatrigger_app type=privapp_data_file levelFrom=all
173-
user=_app seinfo=base minTargetSdkVersion=30 domain=untrusted_app type=app_data_file levelFrom=all
173+
user=_app seinfo=base minTargetSdkVersion=30 domain=untrusted_base_app type=app_data_file levelFrom=all
174174
user=_app minTargetSdkVersion=30 domain=untrusted_app type=app_data_file levelFrom=all
175-
user=_app seinfo=base minTargetSdkVersion=29 domain=untrusted_app_29 type=app_data_file levelFrom=all
175+
user=_app seinfo=base minTargetSdkVersion=29 domain=untrusted_base_app_29 type=app_data_file levelFrom=all
176176
user=_app minTargetSdkVersion=29 domain=untrusted_app_29 type=app_data_file levelFrom=all
177-
user=_app seinfo=base minTargetSdkVersion=28 domain=untrusted_app_27 type=app_data_file levelFrom=all
177+
user=_app seinfo=base minTargetSdkVersion=28 domain=untrusted_base_app_27 type=app_data_file levelFrom=all
178178
user=_app minTargetSdkVersion=28 domain=untrusted_app_27 type=app_data_file levelFrom=all
179-
user=_app seinfo=base minTargetSdkVersion=26 domain=untrusted_app_27 type=app_data_file levelFrom=user
179+
user=_app seinfo=base minTargetSdkVersion=26 domain=untrusted_base_app_27 type=app_data_file levelFrom=user
180180
user=_app minTargetSdkVersion=26 domain=untrusted_app_27 type=app_data_file levelFrom=user
181-
user=_app seinfo=base domain=untrusted_app_25 type=app_data_file levelFrom=user
181+
user=_app seinfo=base domain=untrusted_base_app_25 type=app_data_file levelFrom=user
182182
user=_app domain=untrusted_app_25 type=app_data_file levelFrom=user
183183
user=_app seinfo=base minTargetSdkVersion=28 fromRunAs=true domain=runas_app levelFrom=all
184184
user=_app minTargetSdkVersion=28 fromRunAs=true domain=runas_app levelFrom=all
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
###
2+
### Untrusted apps.
3+
###
4+
### This file defines the rules for untrusted apps running with
5+
### targetSdkVersion >= 30.
6+
###
7+
### See public/untrusted_app.te for more information about which apps are
8+
### placed in this selinux domain.
9+
###
10+
11+
typeattribute untrusted_base_app coredomain;
12+
13+
app_domain(untrusted_base_app)
14+
untrusted_app_domain(untrusted_base_app)
15+
net_domain(untrusted_base_app)
16+
bluetooth_domain(untrusted_base_app)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
###
2+
### untrusted_base_app_25
3+
###
4+
### This file defines the rules for untrusted apps running with
5+
### targetSdkVersion <= 25.
6+
###
7+
### See public/untrusted_app.te for more information about which apps are
8+
### placed in this selinux domain.
9+
###
10+
11+
typeattribute untrusted_base_app_25 coredomain;
12+
13+
app_domain(untrusted_base_app_25)
14+
untrusted_app_domain(untrusted_base_app_25)
15+
net_domain(untrusted_base_app_25)
16+
bluetooth_domain(untrusted_base_app_25)
17+
18+
# b/35917228 - /proc/misc access
19+
# This will go away in a future Android release
20+
allow untrusted_base_app_25 proc_misc:file r_file_perms;
21+
22+
# Access to /proc/tty/drivers, to allow apps to determine if they
23+
# are running in an emulated environment.
24+
# b/33214085 b/33814662 b/33791054 b/33211769
25+
# https://github.com/strazzere/anti-emulator/blob/master/AntiEmulator/src/diff/strazzere/anti/emulator/FindEmulator.java
26+
# This will go away in a future Android release
27+
allow untrusted_base_app_25 proc_tty_drivers:file r_file_perms;
28+
29+
# Text relocation support for API < 23. This is now disallowed for targetSdkVersion>=Q.
30+
# https://android.googlesource.com/platform/bionic/+/master/android-changes-for-ndk-developers.md#text-relocations-enforced-for-api-level-23
31+
allow untrusted_base_app_25 { apk_data_file app_data_file asec_public_file }:file execmod;
32+
33+
# The ability to call exec() on files in the apps home directories
34+
# for targetApi<=25. This is also allowed for targetAPIs 26, 27,
35+
# and 28 in untrusted_app_27.te.
36+
allow untrusted_base_app_25 app_data_file:file execute_no_trans;
37+
auditallow untrusted_base_app_25 app_data_file:file { execute execute_no_trans };
38+
39+
# The ability to invoke dex2oat. Historically required by ART, now only
40+
# allowed for targetApi<=28 for compat reasons.
41+
allow untrusted_base_app_25 dex2oat_exec:file rx_file_perms;
42+
userdebug_or_eng(`auditallow untrusted_base_app_25 dex2oat_exec:file rx_file_perms;')
43+
44+
# The ability to talk to /dev/ashmem directly. targetApi>=29 must use
45+
# ASharedMemory instead.
46+
allow untrusted_base_app_25 ashmem_device:chr_file rw_file_perms;
47+
auditallow untrusted_base_app_25 ashmem_device:chr_file open;
48+
49+
# Read /mnt/sdcard symlink.
50+
allow untrusted_base_app_25 mnt_sdcard_file:lnk_file r_file_perms;
51+
52+
# allow binding to netlink route sockets and sending RTM_GETLINK messages.
53+
allow untrusted_base_app_25 self:netlink_route_socket { bind nlmsg_readpriv };
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
###
2+
### Untrusted_27.
3+
###
4+
### This file defines the rules for untrusted apps running with
5+
### 25 < targetSdkVersion <= 28.
6+
###
7+
### See public/untrusted_app.te for more information about which apps are
8+
### placed in this selinux domain.
9+
###
10+
11+
typeattribute untrusted_base_app_27 coredomain;
12+
13+
app_domain(untrusted_base_app_27)
14+
untrusted_app_domain(untrusted_base_app_27)
15+
net_domain(untrusted_base_app_27)
16+
bluetooth_domain(untrusted_base_app_27)
17+
18+
# Text relocation support for API < 23. This is now disallowed for targetSdkVersion>=Q.
19+
# https://android.googlesource.com/platform/bionic/+/master/android-changes-for-ndk-developers.md#text-relocations-enforced-for-api-level-23
20+
allow untrusted_base_app_27 { apk_data_file app_data_file asec_public_file }:file execmod;
21+
22+
# The ability to call exec() on files in the apps home directories
23+
# for targetApi 26, 27, and 28.
24+
allow untrusted_base_app_27 app_data_file:file execute_no_trans;
25+
auditallow untrusted_base_app_27 app_data_file:file { execute execute_no_trans };
26+
27+
# The ability to invoke dex2oat. Historically required by ART, now only
28+
# allowed for targetApi<=28 for compat reasons.
29+
allow untrusted_base_app_27 dex2oat_exec:file rx_file_perms;
30+
userdebug_or_eng(`auditallow untrusted_base_app_27 dex2oat_exec:file rx_file_perms;')
31+
32+
# The ability to talk to /dev/ashmem directly. targetApi>=29 must use
33+
# ASharedMemory instead.
34+
allow untrusted_base_app_27 ashmem_device:chr_file rw_file_perms;
35+
auditallow untrusted_base_app_27 ashmem_device:chr_file open;
36+
37+
# Read /mnt/sdcard symlink.
38+
allow untrusted_base_app_27 mnt_sdcard_file:lnk_file r_file_perms;
39+
40+
# allow binding to netlink route sockets and sending RTM_GETLINK messages.
41+
allow untrusted_base_app_27 self:netlink_route_socket { bind nlmsg_readpriv };
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
###
2+
### Untrusted_29.
3+
###
4+
### This file defines the rules for untrusted apps running with
5+
### targetSdkVersion = 29.
6+
###
7+
### See public/untrusted_app.te for more information about which apps are
8+
### placed in this selinux domain.
9+
###
10+
11+
typeattribute untrusted_base_app_29 coredomain;
12+
13+
app_domain(untrusted_base_app_29)
14+
untrusted_app_domain(untrusted_base_app_29)
15+
net_domain(untrusted_base_app_29)
16+
bluetooth_domain(untrusted_base_app_29)
17+
18+
# allow binding to netlink route sockets and sending RTM_GETLINK messages.
19+
allow untrusted_base_app_29 self:netlink_route_socket { bind nlmsg_readpriv };

prebuilts/api/30.0/public/domain.te

+3-1
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ neverallow * self:process { execstack execheap };
11281128

11291129
# Do not allow the introduction of new execmod rules. Text relocations
11301130
# and modification of executable pages are unsafe.
1131-
neverallow { domain -untrusted_app_25 -untrusted_app_27 } file_type:file execmod;
1131+
neverallow { domain -untrusted_app_25 -untrusted_base_app_25 -untrusted_app_27 -untrusted_base_app_27 } file_type:file execmod;
11321132

11331133
neverallow { domain -init } proc:{ file dir } mounton;
11341134

@@ -1421,5 +1421,7 @@ neverallow {
14211421
domain
14221422
-ephemeral_app # We don't distinguish ephemeral apps based on target API.
14231423
-untrusted_app_25
1424+
-untrusted_base_app_25
14241425
-untrusted_app_27
1426+
-untrusted_base_app_27
14251427
} ashmem_device:chr_file open;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
###
2+
### Untrusted apps.
3+
###
4+
### Apps are labeled based on mac_permissions.xml (maps signer and
5+
### optionally package name to seinfo value) and seapp_contexts (maps UID
6+
### and optionally seinfo value to domain for process and type for data
7+
### directory). The untrusted_app domain is the default assignment in
8+
### seapp_contexts for any app with UID between APP_AID (10000)
9+
### and AID_ISOLATED_START (99000) if the app has no specific seinfo
10+
### value as determined from mac_permissions.xml. In current AOSP, this
11+
### domain is assigned to all non-system apps as well as to any system apps
12+
### that are not signed by the platform key. To move
13+
### a system app into a specific domain, add a signer entry for it to
14+
### mac_permissions.xml and assign it one of the pre-existing seinfo values
15+
### or define and use a new seinfo value in both mac_permissions.xml and
16+
### seapp_contexts.
17+
###
18+
19+
type untrusted_base_app, domain;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
###
2+
### Untrusted apps.
3+
###
4+
### Apps are labeled based on mac_permissions.xml (maps signer and
5+
### optionally package name to seinfo value) and seapp_contexts (maps UID
6+
### and optionally seinfo value to domain for process and type for data
7+
### directory). The untrusted_app domain is the default assignment in
8+
### seapp_contexts for any app with UID between APP_AID (10000)
9+
### and AID_ISOLATED_START (99000) if the app has no specific seinfo
10+
### value as determined from mac_permissions.xml. In current AOSP, this
11+
### domain is assigned to all non-system apps as well as to any system apps
12+
### that are not signed by the platform key. To move
13+
### a system app into a specific domain, add a signer entry for it to
14+
### mac_permissions.xml and assign it one of the pre-existing seinfo values
15+
### or define and use a new seinfo value in both mac_permissions.xml and
16+
### seapp_contexts.
17+
###
18+
19+
type untrusted_base_app_25, domain;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
###
2+
### Untrusted apps.
3+
###
4+
### Apps are labeled based on mac_permissions.xml (maps signer and
5+
### optionally package name to seinfo value) and seapp_contexts (maps UID
6+
### and optionally seinfo value to domain for process and type for data
7+
### directory). The untrusted_app domain is the default assignment in
8+
### seapp_contexts for any app with UID between APP_AID (10000)
9+
### and AID_ISOLATED_START (99000) if the app has no specific seinfo
10+
### value as determined from mac_permissions.xml. In current AOSP, this
11+
### domain is assigned to all non-system apps as well as to any system apps
12+
### that are not signed by the platform key. To move
13+
### a system app into a specific domain, add a signer entry for it to
14+
### mac_permissions.xml and assign it one of the pre-existing seinfo values
15+
### or define and use a new seinfo value in both mac_permissions.xml and
16+
### seapp_contexts.
17+
###
18+
19+
type untrusted_base_app_27, domain;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
###
2+
### Untrusted apps.
3+
###
4+
### Apps are labeled based on mac_permissions.xml (maps signer and
5+
### optionally package name to seinfo value) and seapp_contexts (maps UID
6+
### and optionally seinfo value to domain for process and type for data
7+
### directory). The untrusted_app domain is the default assignment in
8+
### seapp_contexts for any app with UID between APP_AID (10000)
9+
### and AID_ISOLATED_START (99000) if the app has no specific seinfo
10+
### value as determined from mac_permissions.xml. In current AOSP, this
11+
### domain is assigned to all non-system apps as well as to any system apps
12+
### that are not signed by the platform key. To move
13+
### a system app into a specific domain, add a signer entry for it to
14+
### mac_permissions.xml and assign it one of the pre-existing seinfo values
15+
### or define and use a new seinfo value in both mac_permissions.xml and
16+
### seapp_contexts.
17+
###
18+
19+
type untrusted_base_app_29, domain;

0 commit comments

Comments
 (0)