Skip to content

Commit

Permalink
Add documentation for LSM sensor
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Fedotov <anfedotoff@yandex-team.ru>
  • Loading branch information
anfedotoff committed Jul 11, 2024
1 parent 6650d60 commit 7025814
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 6 deletions.
58 changes: 58 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,64 @@ 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:

```
$ cat /boot/config-$(uname -r) | grep BPF_LSM
CONFIG_BPF_LSM=y
```

If the output contains `CONFIG_BPF_LSM=y`, BPF LSM is supported.
Then, if provided above conditions are met, use this command to check if BPF LSM is enabled:

```
$ cat /sys/kernel/security/lsm
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 7025814

Please sign in to comment.