Skip to content

Commit

Permalink
Add documentation for LSM sensor
Browse files Browse the repository at this point in the history
Adding section about LSM hook points.

Signed-off-by: Andrei Fedotov <[email protected]>
  • Loading branch information
anfedotoff committed Jul 15, 2024
1 parent 7aaa765 commit cd921bb
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 6 deletions.
67 changes: 67 additions & 0 deletions docs/content/en/docs/concepts/tracing-policy/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,73 @@ spec:
This example shows how to use uprobes to hook into the readline function
running in all the bash shells.
## LSM BPF
LSM BPF programs allow runtime instrumentation of the LSM hooks by privileged
users to implement system-wide MAC (Mandatory Access Control) and Audit policies
using eBPF.
List of LSM hooks which can be instrumented can be found in `security/security.c`.

To verify if BPF LSM is available use the following command:

```shell
cat /boot/config-$(uname -r) | grep BPF_LSM
```

The output should be similar to this if BPF LSM is supported:

```
CONFIG_BPF_LSM=y
```

Then, if provided above conditions are met, use this command to check if BPF LSM is enabled:

```shell
cat /sys/kernel/security/lsm
```

The output might look like this:

```
bpf,lockdown,integrity,apparmor
```

If the output includes the `bpf`, than BPF LSM is enabled. Otherwise, you can modify `/etc/default/grub`:

```
GRUB_CMDLINE_LINUX="lsm=lockdown,integrity,apparmor,bpf"
```

Then, update the grub configuration and restart the system.

The provided example of LSM BPF `TracingPolicy` monitors access to files
`/etc/passwd` and `/etc/shadow` with `/usr/bin/cat` executable.

```yaml
apiVersion: cilium.io/v1alpha1
kind: TracingPolicy
metadata:
name: "lsm-file-open"
spec:
lsmhooks:
- hook: "file_open"
args:
- index: 0
type: "file"
selectors:
- matchBinaries:
- operator: "In"
values:
- "/usr/bin/cat"
matchArgs:
- index: 0
operator: "Equal"
values:
- "/etc/passwd"
- "/etc/shadow"
```

## Arguments

Kprobes, uprobes and tracepoints all share a needed arguments fields called `args`. It is a list of
Expand Down
17 changes: 17 additions & 0 deletions docs/content/en/docs/reference/grpc-api.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/content/en/docs/reference/helm-chart.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions docs/content/en/docs/reference/metrics.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cd921bb

Please sign in to comment.