2018-01-03 00:31:18 +01:00
|
|
|
# bpf program loader
|
|
|
|
type bpfloader, domain;
|
2018-09-27 19:21:37 +02:00
|
|
|
type bpfloader_exec, system_file_type, exec_type, file_type;
|
2018-01-03 00:31:18 +01:00
|
|
|
typeattribute bpfloader coredomain;
|
|
|
|
|
|
|
|
# Process need CAP_NET_ADMIN to run bpf programs as cgroup filter
|
|
|
|
allow bpfloader self:global_capability_class_set net_admin;
|
|
|
|
|
|
|
|
r_dir_file(bpfloader, cgroup_bpf)
|
|
|
|
|
|
|
|
# These permission is required for pin bpf program for netd.
|
|
|
|
allow bpfloader fs_bpf:dir create_dir_perms;
|
|
|
|
allow bpfloader fs_bpf:file create_file_perms;
|
|
|
|
allow bpfloader devpts:chr_file { read write };
|
|
|
|
|
2018-03-06 05:43:45 +01:00
|
|
|
allow bpfloader netd:fd use;
|
2018-01-03 00:31:18 +01:00
|
|
|
|
|
|
|
# Use pinned bpf map files from netd.
|
|
|
|
allow bpfloader netd:bpf { map_read map_write };
|
|
|
|
allow bpfloader self:bpf { prog_load prog_run };
|
|
|
|
|
2018-09-13 20:07:14 +02:00
|
|
|
dontaudit bpfloader self:global_capability_class_set sys_admin;
|
|
|
|
|
|
|
|
###
|
|
|
|
### Neverallow rules
|
|
|
|
###
|
2018-03-20 23:42:44 +01:00
|
|
|
neverallow { domain -bpfloader } *:bpf prog_load;
|
2018-03-29 01:51:26 +02:00
|
|
|
neverallow { domain -bpfloader -netd -netutils_wrapper} *:bpf prog_run;
|
2018-01-03 00:31:18 +01:00
|
|
|
neverallow { domain -netd -bpfloader } bpfloader_exec:file { execute execute_no_trans };
|
|
|
|
neverallow bpfloader domain:{ tcp_socket udp_socket rawip_socket } *;
|
|
|
|
# only system_server, netd and bpfloader can read/write the bpf maps
|
|
|
|
neverallow { domain -system_server -netd -bpfloader} netd:bpf { map_read map_write };
|
2018-05-23 17:36:40 +02:00
|
|
|
|
2018-09-13 20:07:14 +02:00
|
|
|
# No domain should be allowed to ptrace bpfloader
|
|
|
|
neverallow { domain userdebug_or_eng(`-llkd') } bpfloader:process ptrace;
|