blob: 0a207e6e1619d15e6fb2d1ea2640c41bdd886230 [file] [log] [blame]
Stephen Smalleye8848722012-11-13 13:00:05 -05001type runas, domain, mlstrustedsubject;
2type runas_exec, file_type;
3
4bool support_runas true;
5
6if (support_runas) {
7
8# ndk-gdb invokes adb shell ps to find the app PID.
9r_dir_file(shell, untrusted_app)
10dontaudit shell domain:dir r_dir_perms;
11dontaudit shell domain:file r_file_perms;
12
13# ndk-gdb invokes adb shell ls to check the app data dir.
14allow shell app_data_file:dir search;
15
16# ndk-gdb invokes adb shell kill -9 to kill the gdbserver.
17allow shell untrusted_app:process sigkill;
18dontaudit shell self:capability { sys_ptrace kill };
19
20# ndk-gdb invokes adb shell run-as.
21domain_auto_trans(shell, runas_exec, runas)
22allow runas shell:fd use;
23allow runas devpts:chr_file { read write };
24
25# run-as reads package information.
26allow runas system_data_file:file r_file_perms;
27
28# run-as checks and changes to the app data dir.
29dontaudit runas self:capability dac_override;
30allow runas self:capability dac_read_search;
31allow runas app_data_file:dir { getattr search };
32
33# run-as switches to the app UID/GID.
34allow runas self:capability { setuid setgid };
35
36# run-as switches to the app security context.
37allow runas rootfs:file r_file_perms; # read /seapp_contexts
38selinux_check_context(runas) # validate context
39allow runas untrusted_app:process dyntransition; # setcon
40
41# run-as runs lib/gdbserver from the app data dir.
42allow untrusted_app system_data_file:file rx_file_perms;
43
44# run-as may also run sh or system commands.
45allow untrusted_app shell_exec:file rx_file_perms;
46allow untrusted_app system_file:file rx_file_perms;
47
48# gdbserver reads the zygote.
49allow untrusted_app zygote_exec:file r_file_perms;
50
51# (grand)child death notification.
52allow untrusted_app shell:process sigchld;
53
54# child shell or gdbserver pty access.
55allow untrusted_app devpts:chr_file { getattr read write };
56
57# gdbserver creates a socket in the app data dir.
58allow untrusted_app app_data_file:sock_file { create unlink };
59
60# ndk-gdb invokes adb forward to forward the gdbserver socket.
61allow adbd app_data_file:dir search;
62allow adbd app_data_file:sock_file write;
63allow adbd untrusted_app:unix_stream_socket connectto;
64
65# ndk-gdb invokes adb pull of app_process, linker, and libc.so.
66allow adbd zygote_exec:file r_file_perms;
67allow adbd system_file:file r_file_perms;
68
69}