@@ -4,6 +4,7 @@ use log::debug;
44
55pub ( super ) struct Checks {
66 pub ( super ) path_hooks_support_bpf_d_path : bool ,
7+ pub ( super ) supports_inode_set_acl : bool ,
78}
89
910impl Checks {
@@ -12,15 +13,31 @@ impl Checks {
1213 . load ( fact_ebpf:: CHECKS_OBJ )
1314 . context ( "Failed to load checks.o" ) ?;
1415
15- let prog = obj
16- . program_mut ( "check_path_unlink_supports_bpf_d_path" )
17- . context ( "Failed to find 'check_path_unlink_supports_bpf_d_path' program" ) ?;
18- let prog: & mut Lsm = prog. try_into ( ) ?;
19- let path_hooks_support_bpf_d_path = prog. load ( "path_unlink" , btf) . is_ok ( ) ;
20- debug ! ( "path_unlink_supports_bpf_d_path: {path_hooks_support_bpf_d_path}" ) ;
16+ let path_hooks_support_bpf_d_path = Self :: probe_hook (
17+ & mut obj,
18+ "check_path_unlink_supports_bpf_d_path" ,
19+ "path_unlink" ,
20+ btf,
21+ ) ;
22+ debug ! ( "path_hooks_support_bpf_d_path: {path_hooks_support_bpf_d_path}" ) ;
23+
24+ let supports_inode_set_acl =
25+ Self :: probe_hook ( & mut obj, "check_inode_set_acl" , "inode_set_acl" , btf) ;
26+ debug ! ( "supports_inode_set_acl: {supports_inode_set_acl}" ) ;
2127
2228 Ok ( Checks {
2329 path_hooks_support_bpf_d_path,
30+ supports_inode_set_acl,
2431 } )
2532 }
33+
34+ fn probe_hook ( obj : & mut aya:: Ebpf , prog_name : & str , hook : & str , btf : & Btf ) -> bool {
35+ let Some ( prog) = obj. program_mut ( prog_name) else {
36+ return false ;
37+ } ;
38+ let Ok ( prog) : Result < & mut Lsm , _ > = prog. try_into ( ) else {
39+ return false ;
40+ } ;
41+ prog. load ( hook, btf) . is_ok ( )
42+ }
2643}
0 commit comments