• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1type bpfloader_exec, system_file_type, exec_type, file_type;
2
3typeattribute bpfloader bpfdomain;
4
5# allow bpfloader to write to the kernel log (starts early)
6allow bpfloader kmsg_device:chr_file w_file_perms;
7
8# These permissions are required to pin ebpf maps & programs.
9allow bpfloader bpffs_type:dir { add_name create remove_name search write };
10allow bpfloader bpffs_type:file { create getattr read rename setattr };
11allow bpfloader bpffs_type:lnk_file { create getattr read };
12allow { bpffs_type -fs_bpf } fs_bpf:filesystem associate;
13
14# Allow bpfloader to create bpf maps and programs.
15allow bpfloader self:bpf { map_create map_read map_write prog_load prog_run };
16
17allow bpfloader self:capability { chown sys_admin net_admin };
18
19allow bpfloader sysfs_fs_fuse_bpf:file r_file_perms;
20
21allow bpfloader proc_bpf:file w_file_perms;
22
23set_prop(bpfloader, bpf_progs_loaded_prop)
24
25allow bpfloader bpfloader_exec:file execute_no_trans;
26
27###
28### Neverallow rules
29###
30
31# Note: we don't care about getattr/mounton/search
32neverallow { domain            } bpffs_type:dir ~{ add_name create getattr mounton remove_name search write };
33neverallow { domain -bpfloader } bpffs_type:dir { add_name create remove_name write };
34
35neverallow { domain            } bpffs_type:file ~{ create getattr map open read rename setattr write };
36neverallow { domain -bpfloader } bpffs_type:file { create map open rename setattr };
37neverallow { domain -bpfloader -gpuservice -lmkd -mediaprovider_app -netd -netutils_wrapper                -system_server } fs_bpf:file               { getattr read };
38neverallow { domain -bpfloader                                                                                            } fs_bpf_loader:file        { getattr read };
39neverallow { domain -bpfloader                                                              -network_stack                } fs_bpf_net_private:file   { getattr read };
40neverallow { domain -bpfloader                                                              -network_stack -system_server } fs_bpf_net_shared:file    { getattr read };
41neverallow { domain -bpfloader                                      -netd                   -network_stack -system_server } fs_bpf_netd_readonly:file { getattr read };
42neverallow { domain -bpfloader                                      -netd -netutils_wrapper -network_stack -system_server } fs_bpf_netd_shared:file   { getattr read };
43neverallow { domain -bpfloader                                                              -network_stack                } fs_bpf_tethering:file     { getattr read };
44neverallow { domain -bpfloader                                                                                            -uprobestats } fs_bpf_uprobestats:file   { getattr read };
45neverallow { domain -bpfloader -gpuservice                          -netd -netutils_wrapper -network_stack -system_server -uprobestats } { bpffs_type -fs_bpf_vendor }:file write;
46
47neverallow { domain -bpfloader } bpffs_type:lnk_file ~read;
48neverallow { domain -bpfdomain } bpffs_type:lnk_file read;
49
50neverallow { domain -bpfloader } *:bpf { map_create prog_load };
51
52# 'fs_bpf_loader' is for internal use of the BpfLoader oneshot boot time process.
53neverallow { domain -bpfloader } fs_bpf_loader:bpf *;
54neverallow { domain -bpfloader } fs_bpf_loader:file *;
55
56neverallow {
57  domain
58  -bpfloader
59  -gpuservice
60  -hal_health_server
61  -mediaprovider_app
62  -netd
63  -netutils_wrapper
64  -network_stack
65  -system_server
66  -uprobestats
67} *:bpf prog_run;
68neverallow { domain -bpfloader -gpuservice -lmkd -mediaprovider_app -netd -network_stack -system_server -uprobestats } *:bpf { map_read map_write };
69neverallow { domain -bpfloader -init } bpfloader_exec:file { execute execute_no_trans };
70
71neverallow { coredomain -bpfloader -netd -netutils_wrapper } fs_bpf_vendor:file *;
72
73neverallow bpfloader *:{ tcp_socket udp_socket rawip_socket } *;
74
75# No domain should be allowed to ptrace bpfloader
76neverallow { domain userdebug_or_eng(`-llkd') } bpfloader:process ptrace;
77
78neverallow { domain -bpfloader } proc_bpf:file write;
79