Debian Codegraph @

man/systemd.image-policy.xml

raw
1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
5
6 <refentry id="systemd.image-policy">
7
8 <refentryinfo>
9 <title>systemd.image-policy</title>
10 <productname>systemd</productname>
11 </refentryinfo>
12
13 <refmeta>
14 <refentrytitle>systemd.image-policy</refentrytitle>
15 <manvolnum>7</manvolnum>
16 </refmeta>
17
18 <refnamediv>
19 <refname>systemd.image-policy</refname>
20 <refpurpose>Disk Image Dissection Policy</refpurpose>
21 </refnamediv>
22
23 <refsect1>
24 <title>Description</title>
25
26 <para>In systemd, whenever a disk image (DDI) implementing the <ulink
27 url="https://uapi-group.org/specifications/specs/discoverable_partitions_specification">UAPI.2
28 Discoverable Partitions Specification</ulink> is activated, a policy may be specified controlling which
29 partitions to mount and what kind of cryptographic protection to require, and which type of filesystem
30 is allowed. Such a disk image dissection policy is a string that contains per-partition-type rules,
31 separated by colons (<literal>:</literal>). The individual rules consist of a partition identifier, an
32 equal sign (<literal>=</literal>), and one or more flags which may be set per partition. If multiple
33 flags are specified per partition they are separated by a plus sign (<literal>+</literal>).</para>
34
35 <para>The partition identifiers currently defined are: <option>root</option>, <option>usr</option>,
36 <option>home</option>, <option>srv</option>, <option>esp</option>, <option>xbootldr</option>,
37 <option>swap</option>, <option>root-verity</option>, <option>root-verity-sig</option>,
38 <option>usr-verity</option>, <option>usr-verity-sig</option>, <option>tmp</option>,
39 <option>var</option>. These identifiers match the relevant partition types in the Discoverable Partitions
40 Specification, but are agnostic to CPU architectures. If the partition identifier is left empty it
41 defines the <emphasis>default</emphasis> policy for partitions defined in the Discoverable Partitions
42 Specification for which no policy flags are explicitly listed in the policy string.</para>
43
44 <para>The following partition policy flags are defined that dictate the existence/absence, the use, and
45 the protection level of partitions:</para>
46
47 <itemizedlist>
48 <listitem><para><option>unprotected</option> for partitions that shall exist and be used, but shall
49 come without cryptographic protection, lacking both Verity authentication and LUKS
50 encryption.</para></listitem>
51
52 <listitem><para><option>verity</option> for partitions that shall exist and be used, with Verity
53 authentication. (Note: if a DDI image carries a data partition, along with a Verity partition and a
54 signature partition for it, and only the <option>verity</option> flag is set (<option>signed</option>
55 is not), then the image will be set up with Verity, but the signature data will not be used. Or in
56 other words: any DDI with a set of partitions that qualify for <option>signature</option> also
57 implicitly qualifies for <option>verity</option>, and in fact also
58 <option>unprotected</option>).</para></listitem>
59
60 <listitem><para><option>signed</option> for partitions that shall exist and be used, with Verity
61 authentication, which are also accompanied by a PKCS#7 signature of the Verity root
62 hash.</para></listitem>
63
64 <listitem><para><option>encrypted</option> for partitions which shall exist and be used and are
65 encrypted with LUKS.</para></listitem>
66
67 <listitem><para><option>unused</option> for partitions that shall exist but shall not be
68 used.</para></listitem>
69
70 <listitem><para><option>absent</option> for partitions that shall not exist on the
71 image.</para></listitem>
72 </itemizedlist>
73
74 <para>The following filesystem policy flags are defined that dictate which filesystem types are allowed
75 for which partition:</para>
76
77 <table>
78 <title>
79 Filesystems types supported by the policy
80 </title>
81
82 <tgroup cols='1'>
83 <thead>
84 <row>
85 <entry>Filesystem flag</entry>
86 </row>
87 </thead>
88 <tbody>
89 <row>
90 <entry><literal>btrfs</literal></entry>
91 </row>
92 <row>
93 <entry><literal>erofs</literal></entry>
94 </row>
95 <row>
96 <entry><literal>ext4</literal></entry>
97 </row>
98 <row>
99 <entry><literal>f2fs</literal></entry>
100 </row>
101 <row>
102 <entry><literal>squashfs</literal></entry>
103 </row>
104 <row>
105 <entry><literal>vfat</literal></entry>
106 </row>
107 <row>
108 <entry><literal>xfs</literal></entry>
109 </row>
110 </tbody>
111 </tgroup>
112 </table>
113
114 <para>By setting a combination of the flags above, alternatives can be declared. For example the
115 combination <literal>unused+absent</literal> means: the partition may exist (in which case it shall not
116 be used) or may be absent. The combination of
117 <literal>unprotected+verity+signed+encrypted+unused+absent</literal> may be specified via the special
118 shortcut <literal>open</literal>, and indicates that the partition may exist or may be absent, but if it
119 exists is used, regardless of the protection level.</para>
120
121 <para>As special rule: if none of the flags above are set for a listed partition identifier, the default
122 policy of <option>open</option> is implied, i.e. setting none of these flags listed above means
123 effectively all flags listed above will be set.</para>
124
125 <para>The following partition policy flags are defined that dictate the state of specific GPT partition
126 flags:</para>
127
128 <itemizedlist>
129 <listitem><para><option>read-only-off</option>, <option>read-only-on</option> to require that the
130 partitions have the read-only partition flag off or on.</para></listitem>
131
132 <listitem><para><option>growfs-off</option>, <option>growfs-on</option> to require that the
133 partitions have the growfs partition flag off or on.</para></listitem>
134 </itemizedlist>
135
136 <para>If both <option>read-only-off</option> and <option>read-only-on</option> are set for a partition,
137 then the state of the read-only flag on the partition is not dictated by the policy. Setting neither flag
138 is equivalent to setting both, i.e. setting neither of these two flags means effectively both will be
139 set. A similar logic applies to <option>growfs-off</option>/<option>growfs-on</option>.</para>
140
141 <para>If partitions are not listed within an image policy string, the default policy flags are applied
142 (configurable via an empty partition identifier, see above). If no default policy flags are configured in
143 the policy string, it is implied to be <literal>absent+unused</literal>, except for the Verity partition
144 and their signature partitions where the policy is automatically derived from minimal protection level of
145 the data partition they protect, as encoded in the policy.</para>
146 </refsect1>
147
148 <refsect1>
149 <title>Special Policies</title>
150
151 <para>The special image policy string <literal>*</literal> is short for "use everything", i.e. is
152 equivalent to:</para>
153
154 <programlisting>=verity+signed+encrypted+unprotected+unused+absent</programlisting>
155
156 <para>The special image policy string <literal>-</literal> is short for "use nothing", i.e. is equivalent
157 to:</para>
158
159 <programlisting>=unused+absent</programlisting>
160
161 <para>The special image policy string <literal>~</literal> is short for "everything must be absent",
162 i.e. is equivalent to:</para>
163
164 <programlisting>=absent</programlisting>
165
166 </refsect1>
167
168 <refsect1>
169 <title>Use</title>
170
171 <para>Most systemd components that support operating with disk images support a
172 <option>--image-policy=</option> command line option to specify the image policy to use, and default to
173 relatively open policies (typically the <literal>*</literal> policy, as described above), under the
174 assumption that trust in disk images is established before the images are passed to the program in
175 question.</para>
176
177 <para>For the host image itself
178 <citerefentry><refentrytitle>systemd-gpt-auto-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>
179 is responsible for processing the GPT partition table and making use of the included discoverable
180 partitions. It accepts an image policy via the kernel command line option
181 <option>systemd.image_policy=</option>.</para>
182
183 <para>Note that image policies do not dictate how the components will mount and use disk images — they
184 only dictate which parts to avoid and which protection level and arrangement to require while
185 mounting/using them. For example,
186 <citerefentry><refentrytitle>systemd-sysext</refentrytitle><manvolnum>8</manvolnum></citerefentry> only
187 cares for the <filename>/usr/</filename> and <filename>/opt/</filename> trees inside a disk image, and
188 thus ignores any <filename>/home/</filename> partitions (and similar) in all cases, which might be
189 included in the image, regardless whether the configured image policy would allow access to it or
190 not. Similar,
191 <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry> is not
192 going to make use of any discovered swap device, regardless of whether the policy would allow that or not.</para>
193
194 <para>Use the <command>image-policy</command> command of the
195 <citerefentry><refentrytitle>systemd-analyze</refentrytitle><manvolnum>1</manvolnum></citerefentry> tool
196 to analyze image policy strings, and determine what a specific policy string means for a specific
197 partition.</para>
198 </refsect1>
199
200 <refsect1>
201 <title>Examples</title>
202
203 <para>The following image policy string dictates one read-only Verity-enabled <filename>/usr/</filename>
204 partition must exist, plus encrypted root and swap partitions. All other partitions are ignored:</para>
205
206 <programlisting>usr=verity+read-only-on:root=encrypted:swap=encrypted</programlisting>
207
208 <para>The following image policy string dictates an encrypted, writable root file system, and optional
209 <filename>/srv/</filename> file system that must be encrypted if it exists and no swap partition may
210 exist:</para>
211
212 <programlisting>root=encrypted+read-only-off:srv=encrypted+absent:swap=absent</programlisting>
213
214 <para>The following image policy string dictates a single root partition that may be encrypted, but
215 does not have to be, and ignores swap partitions, and uses all other partitions if they are available, possibly with encryption.</para>
216
217 <programlisting>root=unprotected+encrypted:swap=absent+unused:=unprotected+encrypted+absent</programlisting>
218
219 <para>The following image policy string dictates a single root partition that can only be erofs or squashfs,
220 and ignores swap partitions, and uses all other partitions if they are available, possibly with encryption.</para>
221
222 <programlisting>root=erofs+squashfs:swap=absent+unused:=unprotected+encrypted+absent</programlisting>
223 </refsect1>
224
225 <refsect1>
226 <title>See Also</title>
227 <para><simplelist type="inline">
228 <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
229 <member><citerefentry><refentrytitle>systemd-dissect</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
230 <member><citerefentry><refentrytitle>systemd-gpt-auto-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
231 <member><citerefentry><refentrytitle>systemd-sysext</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
232 <member><citerefentry><refentrytitle>systemd-analyze</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
233 </simplelist></para>
234 </refsect1>
235
236 </refentry>