Skip to content

Commit f4c9505

Browse files
renlordrandomhydrosol
authored andcommitted
split base isolated app
Signed-off-by: anupritaisno1 <[email protected]>
1 parent d135986 commit f4c9505

34 files changed

+466
-118
lines changed

prebuilts/api/30.0/private/app_neverallows.te

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
define(`all_untrusted_apps',`{
66
ephemeral_app
77
isolated_app
8+
isolated_base_app
89
mediaprovider
910
mediaprovider_app
1011
untrusted_app

prebuilts/api/30.0/private/app_zygote.te

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ allow app_zygote self:global_capability_class_set setpcap;
1616
# Switch SELinux context to isolated app domain.
1717
allow app_zygote self:process setcurrent;
1818
allow app_zygote isolated_app:process dyntransition;
19+
allow app_zygote isolated_base_app:process dyntransition;
1920

2021
# For JIT
2122
allow app_zygote self:process execmem;
@@ -30,6 +31,7 @@ allow app_zygote system_server:process getpgid;
3031

3132
# Interaction between the app_zygote and its children.
3233
allow app_zygote isolated_app:process setpgid;
34+
allow app_zygote isolated_base_app:process setpgid;
3335

3436
# TODO (b/63631799) fix this access
3537
dontaudit app_zygote mnt_expand_file:dir getattr;
@@ -75,7 +77,7 @@ unix_socket_send(app_zygote, system_unsolzygote, system_server)
7577
#####
7678

7779
# Only permit transition to isolated_app.
78-
neverallow app_zygote { domain -isolated_app }:process dyntransition;
80+
neverallow app_zygote { domain -isolated_app -isolated_base_app }:process dyntransition;
7981

8082
# Only setcon() transitions, no exec() based transitions, except for crash_dump.
8183
neverallow app_zygote { domain -crash_dump }:process transition;

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

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
iorapd_exec
104104
iorapd_service
105105
iorapd_tmpfs
106+
isolated_base_app
106107
kmsg_debug_device
107108
last_boot_reason_prop
108109
llkd

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

+1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
iorapd_exec
9595
iorapd_service
9696
iorapd_tmpfs
97+
isolated_base_app
9798
last_boot_reason_prop
9899
llkd
99100
llkd_exec

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

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
iorapd_data_file
9696
iorapd_service
9797
iorapd_tmpfs
98+
isolated_base_app
9899
mediaswcodec
99100
mediaswcodec_exec
100101
mediaswcodec_tmpfs

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

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
iorap_prefetcherd_data_file
7373
iorap_prefetcherd_exec
7474
iorap_prefetcherd_tmpfs
75+
isolated_base_app
7576
mediatranscoding_service
7677
mediatranscoding
7778
mediatranscoding_exec
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
###
2+
### Services with isolatedProcess=true in their manifest.
3+
###
4+
### This file defines the rules for isolated apps. An "isolated
5+
### app" is an APP with UID between AID_ISOLATED_START (99000)
6+
### and AID_ISOLATED_END (99999).
7+
###
8+
9+
typeattribute isolated_base_app coredomain;
10+
11+
app_domain(isolated_base_app)
12+
13+
# Access already open app data files received over Binder or local socket IPC.
14+
allow isolated_base_app { app_data_file privapp_data_file }:file { append read write getattr lock map };
15+
16+
# Allow access to network sockets received over IPC. New socket creation is not
17+
# permitted.
18+
allow isolated_base_app { ephemeral_app priv_app untrusted_app_all }:{ tcp_socket udp_socket } { rw_socket_perms_no_ioctl };
19+
20+
allow isolated_base_app activity_service:service_manager find;
21+
allow isolated_base_app display_service:service_manager find;
22+
allow isolated_base_app webviewupdate_service:service_manager find;
23+
24+
# Google Breakpad (crash reporter for Chrome) relies on ptrace
25+
# functionality. Without the ability to ptrace, the crash reporter
26+
# tool is broken.
27+
# b/20150694
28+
# https://code.google.com/p/chromium/issues/detail?id=475270
29+
allow isolated_base_app self:process ptrace;
30+
31+
# b/32896414: Allow accessing sdcard file descriptors passed to isolated_base_apps
32+
# by other processes. Open should never be allowed, and is blocked by
33+
# neverallow rules below.
34+
# media_rw_data_file is included for sdcardfs, and can be removed if sdcardfs
35+
# is modified to change the secontext when accessing the lower filesystem.
36+
allow isolated_base_app { sdcard_type media_rw_data_file }:file { read write append getattr lock map };
37+
38+
# For webviews, isolated_base_app processes can be forked from the webview_zygote
39+
# in addition to the zygote. Allow access to resources inherited from the
40+
# webview_zygote process. These rules are specialized copies of the ones in app.te.
41+
# Inherit FDs from the webview_zygote.
42+
allow isolated_base_app webview_zygote:fd use;
43+
# Notify webview_zygote of child death.
44+
allow isolated_base_app webview_zygote:process sigchld;
45+
# Inherit logd write socket.
46+
allow isolated_base_app webview_zygote:unix_dgram_socket write;
47+
# Read system properties managed by webview_zygote.
48+
allow isolated_base_app webview_zygote_tmpfs:file read;
49+
50+
# Inherit FDs from the app_zygote.
51+
allow isolated_base_app app_zygote:fd use;
52+
# Notify app_zygote of child death.
53+
allow isolated_base_app app_zygote:process sigchld;
54+
# Inherit logd write socket.
55+
allow isolated_base_app app_zygote:unix_dgram_socket write;
56+
57+
# TODO (b/63631799) fix this access
58+
# suppress denials to /data/local/tmp
59+
dontaudit isolated_base_app shell_data_file:dir search;
60+
61+
# Write app-specific trace data to the Perfetto traced damon. This requires
62+
# connecting to its producer socket and obtaining a (per-process) tmpfs fd.
63+
perfetto_producer(isolated_base_app)
64+
65+
# Allow profiling if the main app has been marked as profileable or
66+
# debuggable.
67+
can_profile_heap(isolated_base_app)
68+
can_profile_perf(isolated_base_app)
69+
70+
#####
71+
##### Neverallow
72+
#####
73+
74+
# Isolated apps should not directly open app data files themselves.
75+
neverallow isolated_base_app { app_data_file privapp_data_file }:file open;
76+
77+
# Only allow appending to /data/anr/traces.txt (b/27853304, b/18340553)
78+
# TODO: are there situations where isolated_base_apps write to this file?
79+
# TODO: should we tighten these restrictions further?
80+
neverallow isolated_base_app anr_data_file:file ~{ open append };
81+
neverallow isolated_base_app anr_data_file:dir ~search;
82+
83+
# Isolated apps must not be permitted to use HwBinder
84+
neverallow isolated_base_app hwbinder_device:chr_file *;
85+
neverallow isolated_base_app *:hwservice_manager *;
86+
87+
# Isolated apps must not be permitted to use VndBinder
88+
neverallow isolated_base_app vndbinder_device:chr_file *;
89+
90+
# Isolated apps must not be permitted to perform actions on Binder and VndBinder service_manager
91+
# except the find actions for services whitelisted below.
92+
neverallow isolated_base_app *:service_manager ~find;
93+
94+
# b/17487348
95+
# Isolated apps can only access three services,
96+
# activity_service, display_service, webviewupdate_service.
97+
neverallow isolated_base_app {
98+
service_manager_type
99+
-activity_service
100+
-display_service
101+
-webviewupdate_service
102+
}:service_manager find;
103+
104+
# Isolated apps shouldn't be able to access the driver directly.
105+
neverallow isolated_base_app gpu_device:chr_file { rw_file_perms execute };
106+
107+
# Do not allow isolated_base_app access to /cache
108+
neverallow isolated_base_app cache_file:dir ~{ r_dir_perms };
109+
neverallow isolated_base_app cache_file:file ~{ read getattr };
110+
111+
# Do not allow isolated_base_app to access external storage, except for files passed
112+
# via file descriptors (b/32896414).
113+
neverallow isolated_base_app { storage_file mnt_user_file sdcard_type }:dir ~getattr;
114+
neverallow isolated_base_app { storage_file mnt_user_file }:file_class_set *;
115+
neverallow isolated_base_app sdcard_type:{ devfile_class_set lnk_file sock_file fifo_file } *;
116+
neverallow isolated_base_app sdcard_type:file ~{ read write append getattr lock map };
117+
118+
# Do not allow USB access
119+
neverallow isolated_base_app { usb_device usbaccessory_device }:chr_file *;
120+
121+
# Restrict the webview_zygote control socket.
122+
neverallow isolated_base_app webview_zygote:sock_file write;
123+
124+
# Limit the /sys files which isolated_base_app can access. This is important
125+
# for controlling isolated_base_app attack surface.
126+
neverallow isolated_base_app {
127+
sysfs_type
128+
-sysfs_devices_system_cpu
129+
-sysfs_transparent_hugepage
130+
-sysfs_usb # TODO: check with audio team if needed for isolated_base_app (b/28417852)
131+
}:file no_rw_file_perms;
132+
133+
# No creation of sockets families other than AF_UNIX sockets.
134+
# List taken from system/sepolicy/public/global_macros - socket_class_set
135+
# excluding unix_stream_socket and unix_dgram_socket.
136+
# Many of these are socket families which have never and will never
137+
# be compiled into the Android kernel.
138+
neverallow isolated_base_app { self ephemeral_app priv_app untrusted_app_all }:{
139+
socket tcp_socket udp_socket rawip_socket netlink_socket packet_socket
140+
key_socket appletalk_socket netlink_route_socket
141+
netlink_tcpdiag_socket netlink_nflog_socket netlink_xfrm_socket
142+
netlink_selinux_socket netlink_audit_socket netlink_dnrt_socket
143+
netlink_kobject_uevent_socket tun_socket netlink_iscsi_socket
144+
netlink_fib_lookup_socket netlink_connector_socket netlink_netfilter_socket
145+
netlink_generic_socket netlink_scsitransport_socket netlink_rdma_socket
146+
netlink_crypto_socket sctp_socket icmp_socket ax25_socket ipx_socket
147+
netrom_socket atmpvc_socket x25_socket rose_socket decnet_socket atmsvc_socket
148+
rds_socket irda_socket pppox_socket llc_socket can_socket tipc_socket
149+
bluetooth_socket iucv_socket rxrpc_socket isdn_socket phonet_socket
150+
ieee802154_socket caif_socket alg_socket nfc_socket vsock_socket kcm_socket
151+
qipcrtr_socket smc_socket xdp_socket
152+
} create;

prebuilts/api/30.0/private/seapp_contexts

+3-3
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ neverallow user=((?!shared_relro).)* domain=shared_relro
125125

126126
# neverallow non-isolated uids into isolated_app domain
127127
# and vice versa
128-
neverallow user=_isolated domain=((?!isolated_app).)*
129-
neverallow user=((?!_isolated).)* domain=isolated_app
128+
neverallow user=_isolated domain=((?!isolated_(base_)?app).)*
129+
neverallow user=((?!_isolated).)* domain=isolated_base_app
130130

131131
# uid shell should always be in shell domain, however non-shell
132132
# uid's can be in shell domain
@@ -152,7 +152,7 @@ user=shared_relro seinfo=base domain=shared_relro
152152
user=shared_relro domain=shared_relro
153153
user=shell seinfo=platform domain=shell name=com.android.shell type=shell_data_file
154154
user=webview_zygote seinfo=webview_zygote domain=webview_zygote
155-
user=_isolated seinfo=base domain=isolated_app levelFrom=user
155+
user=_isolated seinfo=base domain=isolated_base_app levelFrom=user
156156
user=_isolated domain=isolated_app levelFrom=user
157157
user=_app seinfo=app_zygote domain=app_zygote levelFrom=user
158158
user=_app seinfo=media domain=mediaprovider name=android.process.media type=app_data_file levelFrom=user

prebuilts/api/30.0/private/technical_debt.cil

+15-15
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,37 @@
77

88
; Apps, except isolated apps, are clients of Allocator HAL
99
; Unfortunately, we can't currently express this in module policy language:
10-
; typeattribute { appdomain -isolated_app } hal_allocator_client;
10+
; typeattribute { appdomain -isolated_app -isolated_base_app } hal_allocator_client;
1111
; typeattribute hal_allocator_client halclientdomain;
12-
(typeattributeset hal_allocator_client ((and (appdomain) ((not (isolated_app))))))
12+
(typeattributeset hal_allocator_client ((and (appdomain) ((not (or (isolated_app) (isolated_base_app)))))))
1313
(typeattributeset halclientdomain (hal_allocator_client))
1414

1515
; Apps, except isolated apps, are clients of OMX-related services
1616
; Unfortunately, we can't currently express this in module policy language:
17-
(typeattributeset hal_omx_client ((and (appdomain) ((not (isolated_app))))))
17+
(typeattributeset hal_omx_client ((and (appdomain) ((not (or (isolated_app) (isolated_base_app)))))))
1818

1919
; Apps, except isolated apps, are clients of Codec2-related services
2020
; Unfortunately, we can't currently express this in module policy language:
21-
(typeattributeset hal_codec2_client ((and (appdomain) ((not (isolated_app))))))
21+
(typeattributeset hal_codec2_client ((and (appdomain) ((not (or (isolated_app) (isolated_base_app)))))))
2222

2323
; Apps, except isolated apps, are clients of Drm-related services
2424
; Unfortunately, we can't currently express this in module policy language:
25-
(typeattributeset hal_drm_client ((and (appdomain) ((not (isolated_app))))))
25+
(typeattributeset hal_drm_client ((and (appdomain) ((not (or (isolated_app) (isolated_base_app)))))))
2626

2727
; Apps, except isolated apps, are clients of Configstore HAL
2828
; Unfortunately, we can't currently express this in module policy language:
29-
; typeattribute { appdomain -isolated_app } hal_configstore_client;
30-
(typeattributeset hal_configstore_client ((and (appdomain) ((not (isolated_app))))))
29+
; typeattribute { appdomain -isolated_app -isolated_base_app } hal_configstore_client;
30+
(typeattributeset hal_configstore_client ((and (appdomain) ((not (or (isolated_app) (isolated_base_app)))))))
3131

3232
; Apps, except isolated apps, are clients of Graphics Allocator HAL
3333
; Unfortunately, we can't currently express this in module policy language:
34-
; typeattribute { appdomain -isolated_app } hal_graphics_allocator_client;
35-
(typeattributeset hal_graphics_allocator_client ((and (appdomain) ((not (isolated_app))))))
34+
; typeattribute { appdomain -isolated_app -isolated_base_app } hal_graphics_allocator_client;
35+
(typeattributeset hal_graphics_allocator_client ((and (appdomain) ((not (or (isolated_app) (isolated_base_app)))))))
3636

3737
; Apps, except isolated apps, are clients of Cas HAL
3838
; Unfortunately, we can't currently express this in module policy language:
39-
; typeattribute { appdomain -isolated_app } hal_cas_client;
40-
(typeattributeset hal_cas_client ((and (appdomain) ((not (isolated_app))))))
39+
; typeattribute { appdomain -isolated_app -isolated_base_app } hal_cas_client;
40+
(typeattributeset hal_cas_client ((and (appdomain) ((not (or (isolated_app) (isolated_base_app)))))))
4141

4242
; Domains hosting Camera HAL implementations are clients of Allocator HAL
4343
; Unfortunately, we can't currently express this in module policy language:
@@ -46,8 +46,8 @@
4646

4747
; Apps, except isolated apps, are clients of Neuralnetworks HAL
4848
; Unfortunately, we can't currently express this in module policy language:
49-
; typeattribute { appdomain -isolated_app } hal_neuralnetworks_client;
50-
(typeattributeset hal_neuralnetworks_client ((and (appdomain) ((not (isolated_app))))))
49+
; typeattribute { appdomain -isolated_app -isolated_base_app } hal_neuralnetworks_client;
50+
(typeattributeset hal_neuralnetworks_client ((and (appdomain) ((not (or (isolated_app) (isolated_base_app)))))))
5151

5252
; TODO(b/112056006): move these to mapping files when/if we implement 'versioned' attributes.
5353
; Rename untrusted_app_visible_* to untrusted_app_visible_*_violators.
@@ -61,5 +61,5 @@
6161

6262
; Apps, except isolated apps, are clients of BufferHub HAL
6363
; Unfortunately, we can't currently express this in module policy language:
64-
; typeattribute { appdomain -isolated_app } hal_cas_client;
65-
(typeattributeset hal_bufferhub_client ((and (appdomain) ((not (isolated_app))))))
64+
; typeattribute { appdomain -isolated_app -isolated_base_app } hal_cas_client;
65+
(typeattributeset hal_bufferhub_client ((and (appdomain) ((not (or (isolated_app) (isolated_base_app)))))))

prebuilts/api/30.0/private/webview_zygote.te

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ allow webview_zygote self:global_capability_class_set setpcap;
2626
# Switch SELinux context to app domains.
2727
allow webview_zygote self:process setcurrent;
2828
allow webview_zygote isolated_app:process dyntransition;
29+
allow webview_zygote isolated_base_app:process dyntransition;
2930

3031
# For art.
3132
allow webview_zygote dalvikcache_data_file:dir r_dir_perms;
@@ -45,6 +46,7 @@ allow webview_zygote system_server:process getpgid;
4546

4647
# Interaction between the webview_zygote and its children.
4748
allow webview_zygote isolated_app:process setpgid;
49+
allow webview_zygote isolated_base_app:process setpgid;
4850

4951
# TODO (b/63631799) fix this access
5052
# Suppress denials to storage. Webview zygote should not be accessing.
@@ -85,7 +87,7 @@ unix_socket_send(webview_zygote, system_unsolzygote, system_server)
8587
#####
8688

8789
# Only permit transition to isolated_app.
88-
neverallow webview_zygote { domain -isolated_app }:process dyntransition;
90+
neverallow webview_zygote { domain -isolated_app -isolated_base_app }:process dyntransition;
8991

9092
# Only setcon() transitions, no exec() based transitions, except for crash_dump.
9193
neverallow webview_zygote { domain -crash_dump }:process transition;

0 commit comments

Comments
 (0)