• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 fs_bpf_tethering }:dir { add_name create search write };
8allow bpfloader { fs_bpf fs_bpf_tethering }:file { create read setattr };
9allow fs_bpf_tethering fs_bpf:filesystem associate;
10
11# Allow bpfloader to create bpf maps and programs.
12allow bpfloader self:bpf { map_create map_read map_write prog_load prog_run };
13
14allow bpfloader self:capability { chown sys_admin net_admin };
15
16set_prop(bpfloader, bpf_progs_loaded_prop)
17
18###
19### Neverallow rules
20###
21
22# TODO: get rid of init & vendor_init; Note: we don't care about getattr/mounton/search
23neverallow { domain -init -vendor_init } { fs_bpf fs_bpf_tethering }:dir { open read setattr };
24neverallow { domain -bpfloader } { fs_bpf fs_bpf_tethering }:dir { add_name create write };
25neverallow domain { fs_bpf fs_bpf_tethering }:dir ~{ add_name create getattr mounton open read search setattr write };
26
27# TODO: get rid of init & vendor_init
28neverallow { domain -bpfloader -init -vendor_init } { fs_bpf fs_bpf_tethering }:file { map open setattr };
29neverallow { domain -bpfloader } { fs_bpf fs_bpf_tethering }:file create;
30neverallow { domain -bpfloader -gpuservice -init -lmkd -netd -netutils_wrapper -network_stack -system_server -vendor_init } { fs_bpf fs_bpf_tethering }:file read;
31neverallow { domain -bpfloader -gpuservice -netd -netutils_wrapper -network_stack -system_server } { fs_bpf fs_bpf_tethering }:file write;
32neverallow domain { fs_bpf fs_bpf_tethering }:file ~{ create map open read setattr write };
33
34neverallow { domain -bpfloader } *:bpf { map_create prog_load };
35neverallow { domain -bpfloader -gpuservice -netd -netutils_wrapper -network_stack -system_server } *:bpf prog_run;
36neverallow { domain -bpfloader -gpuservice -lmkd -netd -network_stack -system_server } *:bpf { map_read map_write };
37
38neverallow { domain -bpfloader -init } bpfloader_exec:file { execute execute_no_trans };
39
40neverallow bpfloader *:{ tcp_socket udp_socket rawip_socket } *;
41
42# No domain should be allowed to ptrace bpfloader
43neverallow { domain userdebug_or_eng(`-llkd') } bpfloader:process ptrace;
44