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;
|
|
|
|
|
|
|
|
# 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-12-05 02:57:27 +01:00
|
|
|
# Allow bpfloader to create bpf maps and programs. The map_read and map_write permission is needed
|
|
|
|
# for retrieving a pinned map when bpfloader do a run time restart.
|
|
|
|
allow bpfloader self:bpf { prog_load prog_run map_read map_write map_create };
|
2018-01-03 00:31:18 +01:00
|
|
|
|
2018-11-28 20:06:49 +01:00
|
|
|
allow bpfloader self:global_capability_class_set sys_admin;
|
2018-09-13 20:07:14 +02:00
|
|
|
|
|
|
|
###
|
|
|
|
### 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-11-29 22:07:40 +01:00
|
|
|
neverallow { domain -bpfloader -init } bpfloader_exec:file { execute execute_no_trans };
|
2018-01-03 00:31:18 +01:00
|
|
|
neverallow bpfloader domain:{ tcp_socket udp_socket rawip_socket } *;
|
|
|
|
# only system_server, netd and bpfloader can read/write the bpf maps
|
2018-12-05 02:57:27 +01:00
|
|
|
neverallow { domain -system_server -netd -bpfloader} *: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;
|
2019-01-11 14:32:45 +01:00
|
|
|
|
|
|
|
set_prop(bpfloader, bpf_progs_loaded_prop)
|