pub struct Lsm { /* private fields */ }
Expand description

A program that attaches to Linux LSM hooks. Used to implement security policy and audit logging.

LSM probes can be attached to the kernel’s security hooks to implement mandatory access control policy and security auditing.

LSM probes require a kernel compiled with CONFIG_BPF_LSM=y and CONFIG_DEBUG_INFO_BTF=y. In order for the probes to fire, you also need the BPF LSM to be enabled through your kernel’s boot paramters (like lsm=lockdown,yama,bpf).

Minimum kernel version

The minimum kernel version required to use this feature is 5.7.

Examples

use aya::{Bpf, programs::Lsm, BtfError, Btf};
use std::convert::TryInto;

let btf = Btf::from_sys_fs()?;
let program: &mut Lsm = bpf.program_mut("lsm_prog").unwrap().try_into()?;
program.load("security_bprm_exec", &btf)?;
program.attach()?;

Implementations

Loads the program inside the kernel.

See also Program::load.

Arguments
  • lsm_hook_name - full name of the LSM hook that the program should be attached to

Attaches the program.

Trait Implementations

Formats the value using the given formatter. Read more

Returns the RawFd of the program if it has been loaded, or None

Returns the RawFd of the program if it has been loaded, or None

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.