summaryrefslogtreecommitdiffstats
path: root/common/cnd.te
blob: 54be97a19e1db06b4b8c2ef31d6fa884784e53f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#permissive cnd;
type cnd, domain, domain_deprecated, mlstrustedsubject;
type cnd_exec, exec_type, file_type;
file_type_auto_trans(cnd, socket_device, cnd_socket);

# cnd is started by init, type transit from init domain to cnd domain
init_daemon_domain(cnd)

# associate netdomain as an attribute of cnd domain
net_domain(cnd)

allow cnd smem_log_device:chr_file rw_file_perms;

# allow cnd the following capability
allow cnd self:capability {
    setuid
    setgid
    dac_override
    net_raw
    chown
    fsetid
    net_admin
    sys_module
    net_bind_service
};

allow cnd self:capability2 block_suspend;

# socket used to communicate with kernel via the netlink syscall
allow cnd self:{
    netlink_tcpdiag_socket
    netlink_route_socket
    netlink_socket
    netlink_generic_socket
    # allow cnd to perform socket operation on itself
    socket
} create_socket_perms;

# allow cnd to read tcp diagnostics through netlink
allow cnd self:netlink_tcpdiag_socket nlmsg_read;

# allow cnd to set system property
allow cnd system_prop:property_service set;
unix_socket_connect(cnd, property, init)

# allow cnd to access cnd_data_file
allow cnd cnd_data_file:file create_file_perms;
allow cnd cnd_data_file:sock_file { unlink create setattr };
allow cnd cnd_data_file:dir rw_dir_perms;

# allow cnd to access qmux_radio_socket
qmux_socket(cnd)

# allow cnd to access wpa_socket
unix_socket_send(cnd, wpa, wpa)
allow cnd wpa_socket:dir rw_dir_perms;
allow cnd wpa_socket:sock_file { create unlink setattr };
allow cnd wifi_data_file:dir r_dir_perms;

# allow cnd to obtain wakelock
wakelock_use(cnd)

# allow cnd to get appname and use inet socket
cnd_nims_socket_perm(appdomain)
cnd_nims_socket_perm(system_server)
cnd_nims_socket_perm(mediaserver)
cnd_nims_socket_perm(mtp)
cnd_nims_socket_perm(wfdservice)
cnd_nims_socket_perm(drmserver)

# allow cnd to access ipa_dev
allow cnd ipa_dev:chr_file rw_file_perms;

# allow access to nims
allow cnd socket_device:dir remove_name;

allow cnd ipacm_data_file:dir r_dir_perms;
allow cnd ipacm_data_file:file r_file_perms;

# explicitly allow udp socket permissions for appdomain
allow cnd appdomain:udp_socket rw_socket_perms;

#allow cnd daemon to invoke hostapd_cli
allow cnd shell_exec:file rx_file_perms;
domain_auto_trans(cnd, hostapd_exec, hostapd)

# only allow getopt for appdomain
allow appdomain zygote:unix_dgram_socket getopt;
dontaudit { domain -appdomain } zygote:unix_dgram_socket getopt;

#diag
userdebug_or_eng(`
    diag_use(cnd)
')