Skip to content

Commit 4b358f4

Browse files
kolyshkincyphar
authored andcommitted
docs/systemd: describe device rules
Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 7b4206c commit 4b358f4

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

docs/systemd.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,42 @@ The following tables summarize which properties are translated.
104104
For documentation on systemd unit resource properties, see
105105
[systemd.resource-control(5)] man page.
106106

107+
### Device access rules
108+
109+
[Device access rules] from the [runtime spec] are translated to systemd properties
110+
(`DevicePolicy` and `DeviceAllow`). Not all configurations are supported; in
111+
particular, the following can not be translated:
112+
- blacklist-style rulesets;
113+
- wildcard-major rules (meaning "all devices with any major number and the
114+
given minor number").
115+
116+
NOTE that systemd v240 or later is highly recommended, since older versions
117+
have limited ways to interpret `DeviceAllow` rules. When using systemd older
118+
than v240, the following limitations exist:
119+
120+
- it is not possible to add a rule for a device that does not have an
121+
equivalent `/dev/{char,block}/<MAJOR>:<minor>` file on the host
122+
(for example, this is the case for NVidia devices);
123+
- adding a wildcard-minor rule (meaning "devices with the given major number
124+
any any minor number") results in having a set of individual rules for
125+
existing devices only, meaning that any devices that will appear after the
126+
container start won't be accessible.
127+
128+
How the device access rules are applied depends on cgroup version:
129+
130+
#### cgroup v1
131+
132+
The rules are applied by systemd to the cgroup device controller
133+
(`device.{allow,deny}` files), then runc overwrites those rules with its own
134+
set, which might be more complete due to older systemd limitations described
135+
above. If some spec rules can not be translated to systemd properties, a
136+
warning is emitted.
137+
138+
#### cgroup v2
139+
140+
The rules are only applied by systemd. If some spec rules can not be translated
141+
to systemd properties (see above), an error is returned.
142+
107143
### Auxiliary properties
108144

109145
Auxiliary properties of a systemd unit (as shown by `systemctl show
@@ -133,3 +169,4 @@ consult systemd sources.
133169
[runtime spec]: https://github.com/opencontainers/runtime-spec/blob/main/spec.md
134170
[Linux.CgroupsPath]: https://github.com/opencontainers/runtime-spec/blob/main/config-linux.md#cgroups-path
135171
[systemd.resource-control(5)]: https://www.freedesktop.org/software/systemd/man/systemd.resource-control.html
172+
[Device access rules]: https://github.com/opencontainers/runtime-spec/blob/main/config-linux.md#allowed-device-list

0 commit comments

Comments
 (0)