1# bpf program loader 2type bpfloader, domain; 3type bpfloader_exec, system_file_type, exec_type, file_type; 4typeattribute bpfloader coredomain; 5 6# These permissions are required to pin ebpf maps & programs. 7allow bpfloader fs_bpf:dir { search write add_name }; 8allow bpfloader fs_bpf:file { create setattr read }; 9 10# Allow bpfloader to create bpf maps and programs. 11allow bpfloader self:bpf { map_create map_read map_write prog_load prog_run }; 12 13allow bpfloader self:capability { chown sys_admin }; 14 15### 16### Neverallow rules 17### 18 19# TODO: get rid of init & vendor_init 20neverallow { domain -init -vendor_init } fs_bpf:dir setattr; 21neverallow { domain -bpfloader } fs_bpf:dir { write add_name }; 22neverallow domain fs_bpf:dir { reparent rename rmdir }; 23 24# TODO: get rid of init & vendor_init 25neverallow { domain -bpfloader -init -vendor_init } fs_bpf:file setattr; 26neverallow { domain -bpfloader } fs_bpf:file create; 27neverallow domain fs_bpf:file { rename unlink }; 28 29neverallow { domain -bpfloader } *:bpf { map_create prog_load }; 30neverallow { domain -bpfloader -netd -netutils_wrapper -system_server } *:bpf prog_run; 31neverallow { domain -bpfloader -netd -system_server } *:bpf { map_read map_write }; 32 33neverallow { domain -bpfloader -init } bpfloader_exec:file { execute execute_no_trans }; 34 35neverallow bpfloader domain:{ tcp_socket udp_socket rawip_socket } *; 36 37# No domain should be allowed to ptrace bpfloader 38neverallow { domain userdebug_or_eng(`-llkd') } bpfloader:process ptrace; 39 40set_prop(bpfloader, bpf_progs_loaded_prop) 41