Skip to content

Commit 2acb0ba

Browse files
committed
doc: Add documentation for bpf token delegation
Signed-off-by: Gwendolyn <[email protected]>
1 parent 91944b4 commit 2acb0ba

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

doc/explanation/bpf-tokens.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
(bpf-tokens)=
2+
# BPF token delegation
3+
4+
Incus supports delegating BPF capabilities via [BPF tokens](https://docs.ebpf.io/linux/concepts/token/).
5+
If any of the instance options {config:option}`instance-security:security.bpffs.delegate_cmds`,
6+
{config:option}`instance-security:security.bpffs.delegate_maps`,
7+
{config:option}`instance-security:security.bpffs.delegate_progs` or
8+
{config:option}`instance-security:security.bpffs.delegate_attachs` is set, Incus mounts a BPF filesystem into the
9+
container at the path specified by the {config:option}`instance-security:security.bpffs.path` option and delegates the
10+
configured capabilities to it.
11+
12+
The permissible values for these options depend on the kernel version and can be found in enums in the BPF header file
13+
(`include/uapi/linux/bpf.h` in the kernel tree, `/usr/include/linux/bpf.h` on most distributions if you have the kernel
14+
sources installed):
15+
16+
Key | Kernel enum | Remove prefix
17+
:-- |:-- | :--
18+
`security.bpffs.delegate_cmds` | `bpf_cmd` | `BPF_`
19+
`security.bpffs.delegate_maps` | `bpf_map_type` | `BPF_MAP_TYPE_`
20+
`security.bpffs.delegate_progs` | `bpf_prog_type` | `BPF_PROG_TYPE_`
21+
`security.bpffs.delegate_attachs` | `bpf_attach_type` | `BPF_`
22+
23+
Each of these options takes a comma-separated list of values, additionally the value `any` is supported to delegate all
24+
possible values of the type.
25+
26+
## Example
27+
28+
Key | Value
29+
:-- | :--
30+
`security.bpffs.delegate_cmds` | `map_create,obj_get,link_create`
31+
`security.bpffs.delegate_maps` | `hash,array,devmap,queue,stack`
32+
`security.bpffs.delegate_progs` | `socket_filter,kprobe,cgroup_sysctl`
33+
`security.bpffs.delegate_attachs` | `any`
34+
35+
```bash
36+
$ mount -t bpf
37+
none on /sys/fs/bpf type bpf (rw,relatime,delegate_cmds=map_create:obj_get:link_create,delegate_maps=hash:array:devmap:queue:stack,delegate_progs=socket_filter:kprobe:cgroup_sysctl,delegate_attachs=any)
38+
```

doc/security.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
:maxdepth: 1
66
77
explanation/security
8+
explanation/bpf-tokens
89
authentication
910
authorization
1011
Expose Incus to the network <howto/server_expose>

0 commit comments

Comments
 (0)