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.
|
2021-01-29 23:36:32 +01:00
|
|
|
allow bpfloader { fs_bpf fs_bpf_tethering }:dir { add_name create search write };
|
|
|
|
allow bpfloader { fs_bpf fs_bpf_tethering }:file { create read setattr };
|
|
|
|
allow fs_bpf_tethering 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-01-29 23:36:32 +01:00
|
|
|
set_prop(bpfloader, bpf_progs_loaded_prop)
|
|
|
|
|
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
|
|
|
|
neverallow { domain -init -vendor_init } { fs_bpf fs_bpf_tethering }:dir { open read setattr };
|
|
|
|
neverallow { domain -bpfloader } { fs_bpf fs_bpf_tethering }:dir { add_name create write };
|
|
|
|
neverallow domain { fs_bpf fs_bpf_tethering }: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
|
2021-01-29 23:36:32 +01:00
|
|
|
neverallow { domain -bpfloader -init -vendor_init } { fs_bpf fs_bpf_tethering }:file { map open setattr };
|
|
|
|
neverallow { domain -bpfloader } { fs_bpf fs_bpf_tethering }:file create;
|
|
|
|
neverallow { domain -bpfloader -gpuservice -init -netd -netutils_wrapper -network_stack -system_server -vendor_init } { fs_bpf fs_bpf_tethering }:file read;
|
|
|
|
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 };
|
2020-11-26 02:55:56 +01:00
|
|
|
neverallow { domain -bpfloader -gpuservice -netd -netutils_wrapper -network_stack -system_server } *:bpf prog_run;
|
|
|
|
neverallow { domain -bpfloader -gpuservice -netd -network_stack -system_server } *:bpf { map_read map_write };
|
2020-01-31 07:08:43 +01:00
|
|
|
|
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
|
|
|
|
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;
|