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
|
|
|
|
2022-02-10 01:32:44 +01:00
|
|
|
typeattribute bpfloader bpfdomain;
|
|
|
|
|
2022-02-08 00:15:00 +01:00
|
|
|
# allow bpfloader to write to the kernel log (starts early)
|
|
|
|
allow bpfloader kmsg_device:chr_file w_file_perms;
|
|
|
|
|
2020-01-31 07:08:43 +01:00
|
|
|
# These permissions are required to pin ebpf maps & programs.
|
2019-12-14 00:18:32 +01:00
|
|
|
allow bpfloader { fs_bpf fs_bpf_tethering fs_bpf_vendor }:dir { add_name create search write };
|
|
|
|
allow bpfloader { fs_bpf fs_bpf_tethering fs_bpf_vendor }:file { create read setattr };
|
|
|
|
allow { fs_bpf_tethering fs_bpf_vendor } fs_bpf:filesystem associate;
|
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
|
|
|
|
2021-03-02 08:16:46 +01:00
|
|
|
allow bpfloader self:capability { chown sys_admin net_admin };
|
2018-09-13 20:07:14 +02:00
|
|
|
|
2021-11-12 01:53:26 +01:00
|
|
|
allow bpfloader sysfs_fs_fuse_bpf:file r_file_perms;
|
|
|
|
|
2021-01-29 23:36:32 +01:00
|
|
|
set_prop(bpfloader, bpf_progs_loaded_prop)
|
|
|
|
|
2022-01-19 07:57:41 +01:00
|
|
|
allow bpfloader bpfloader_exec:file execute_no_trans;
|
|
|
|
|
2018-09-13 20:07:14 +02:00
|
|
|
###
|
|
|
|
### Neverallow rules
|
|
|
|
###
|
2020-01-31 07:08:43 +01:00
|
|
|
|
2021-01-29 23:36:32 +01:00
|
|
|
# TODO: get rid of init & vendor_init; Note: we don't care about getattr/mounton/search
|
2019-12-14 00:18:32 +01:00
|
|
|
neverallow { domain -init -vendor_init } { fs_bpf fs_bpf_tethering fs_bpf_vendor }:dir { open read setattr };
|
|
|
|
neverallow { domain -bpfloader } { fs_bpf fs_bpf_tethering fs_bpf_vendor }:dir { add_name create write };
|
|
|
|
neverallow domain { fs_bpf fs_bpf_tethering fs_bpf_vendor }:dir ~{ add_name create getattr mounton open read search setattr write };
|
2020-01-31 07:08:43 +01:00
|
|
|
|
|
|
|
# TODO: get rid of init & vendor_init
|
2019-12-14 00:18:32 +01:00
|
|
|
neverallow { domain -bpfloader -init -vendor_init } { fs_bpf fs_bpf_tethering fs_bpf_vendor }:file { map open setattr };
|
|
|
|
neverallow { domain -bpfloader } { fs_bpf fs_bpf_tethering fs_bpf_vendor }:file create;
|
2021-11-11 19:42:11 +01:00
|
|
|
neverallow { domain -bpfloader -gpuservice -init -lmkd -mediaprovider_app -netd -netutils_wrapper -network_stack -system_server -vendor_init } { fs_bpf }:file read;
|
|
|
|
neverallow { domain -bpfloader -gpuservice -init -lmkd -netd -netutils_wrapper -network_stack -system_server -vendor_init } { fs_bpf_tethering }:file read;
|
2021-01-29 23:36:32 +01:00
|
|
|
neverallow { domain -bpfloader -gpuservice -netd -netutils_wrapper -network_stack -system_server } { fs_bpf fs_bpf_tethering }:file write;
|
|
|
|
neverallow domain { fs_bpf fs_bpf_tethering }:file ~{ create map open read setattr write };
|
2020-01-31 07:08:43 +01:00
|
|
|
|
2019-04-09 06:34:53 +02:00
|
|
|
neverallow { domain -bpfloader } *:bpf { map_create prog_load };
|
2019-12-14 00:18:32 +01:00
|
|
|
|
2021-11-11 19:42:11 +01:00
|
|
|
neverallow { domain -bpfloader -gpuservice -mediaprovider_app -netd -netutils_wrapper -network_stack -system_server } *:bpf prog_run;
|
|
|
|
neverallow { domain -bpfloader -gpuservice -lmkd -mediaprovider_app -netd -network_stack -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
|
|
|
|
2019-12-14 00:18:32 +01:00
|
|
|
neverallow { coredomain -bpfloader -init } fs_bpf_vendor:file *;
|
|
|
|
|
2021-01-29 23:36:32 +01:00
|
|
|
neverallow bpfloader *:{ 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;
|
2021-11-11 10:51:15 +01:00
|
|
|
|
|
|
|
# Currently only bpfloader.rc (which runs as init) can do bpf sysctl setup
|
|
|
|
# this should perhaps be moved to the bpfloader binary itself. Allow both.
|
|
|
|
neverallow { domain -bpfloader -init } proc_bpf:file write;
|