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;
|
|
|
|
|
2020-01-31 07:08:43 +01:00
|
|
|
# These permissions are required to pin ebpf maps & programs.
|
|
|
|
allow bpfloader fs_bpf:dir { search write add_name };
|
|
|
|
allow bpfloader fs_bpf:file { create setattr };
|
2018-01-03 00:31:18 +01:00
|
|
|
|
2020-01-31 07:08:43 +01:00
|
|
|
# Allow bpfloader to create bpf maps and programs.
|
|
|
|
allow bpfloader self:bpf { map_create map_read map_write prog_load prog_run };
|
2018-01-03 00:31:18 +01:00
|
|
|
|
2020-01-27 16:10:40 +01:00
|
|
|
allow bpfloader self:capability { chown sys_admin };
|
2018-09-13 20:07:14 +02:00
|
|
|
|
|
|
|
###
|
|
|
|
### Neverallow rules
|
|
|
|
###
|
2020-01-31 07:08:43 +01:00
|
|
|
|
|
|
|
# TODO: get rid of init & vendor_init
|
|
|
|
neverallow { domain -init -vendor_init } fs_bpf:dir setattr;
|
|
|
|
neverallow { domain -bpfloader } fs_bpf:dir { write add_name };
|
|
|
|
neverallow domain fs_bpf:dir { reparent rename rmdir };
|
|
|
|
|
|
|
|
# TODO: get rid of init & vendor_init
|
|
|
|
neverallow { domain -bpfloader -init -vendor_init } fs_bpf:file setattr;
|
|
|
|
neverallow { domain -bpfloader } fs_bpf:file create;
|
|
|
|
neverallow domain fs_bpf:file { rename unlink };
|
|
|
|
|
2019-04-09 06:34:53 +02:00
|
|
|
neverallow { domain -bpfloader } *:bpf { map_create prog_load };
|
2020-01-15 00:45:55 +01:00
|
|
|
neverallow { domain -bpfloader -netd -netutils_wrapper -system_server } *:bpf prog_run;
|
2020-01-31 07:08:43 +01:00
|
|
|
neverallow { domain -bpfloader -netd -system_server } *:bpf { map_read map_write };
|
|
|
|
|
2018-11-29 22:07:40 +01:00
|
|
|
neverallow { domain -bpfloader -init } bpfloader_exec:file { execute execute_no_trans };
|
2020-01-31 07:08:43 +01:00
|
|
|
|
2018-01-03 00:31:18 +01:00
|
|
|
neverallow bpfloader domain:{ tcp_socket udp_socket rawip_socket } *;
|
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)
|