diff --git a/aya/src/sys/feature_probe.rs b/aya/src/sys/feature_probe.rs index 0dd06120..e19b48c9 100644 --- a/aya/src/sys/feature_probe.rs +++ b/aya/src/sys/feature_probe.rs @@ -21,7 +21,7 @@ use super::{ use crate::{ MockableFd, maps::MapType, - programs::{ProgramError, ProgramType}, + programs::{LsmAttachType, ProgramError, ProgramType}, util::page_size, }; @@ -159,7 +159,10 @@ pub fn is_program_supported(program_type: ProgramType) -> Result {} + Err(err) => match err { + ProgramError::LoadError { io_error, .. } + if !is_program_supported(ProgramType::Lsm(LsmAttachType::Cgroup)).unwrap() => + { + assert_eq!(io_error.raw_os_error(), Some(libc::EINVAL)); + eprintln!("skipping test - LSM cgroup programs not supported at load"); + return; + } + err => panic!("unexpected error loading LSM cgroup program: {err}"), + }, + } assert_matches!(std::net::TcpListener::bind("127.0.0.1:0"), Ok(_)); @@ -68,12 +81,15 @@ fn lsm_cgroup() { let link_id = { let result = prog.attach(cgroup.fd()); - if !is_program_supported(ProgramType::Lsm(LsmAttachType::Cgroup)).unwrap() { + // See https://www.exein.io/blog/exploring-bpf-lsm-support-on-aarch64-with-ftrace. + if cfg!(target_arch = "aarch64") + && KernelVersion::current().unwrap() < KernelVersion::new(6, 4, 0) + { assert_matches!(result, Err(ProgramError::SyscallError(SyscallError { call, io_error })) => { assert_eq!(call, "bpf_link_create"); assert_eq!(io_error.raw_os_error(), Some(524)); }); - eprintln!("skipping test - LSM programs not supported"); + eprintln!("skipping test - LSM cgroup programs not supported at attach"); return; } result.unwrap()