Fixed the build error for riscv64 arch using gcc 13
[platform/upstream/cryptsetup.git] / man / veritysetup.8
1 .TH VERITYSETUP "8" "January 2021" "veritysetup" "Maintenance Commands"
2 .SH NAME
3 veritysetup - manage dm-verity (block level verification) volumes
4 .SH SYNOPSIS
5 .B veritysetup <options> <action> <action args>
6 .SH DESCRIPTION
7 .PP
8 Veritysetup is used to configure dm-verity managed device-mapper mappings.
9
10 Device-mapper verity target provides read-only transparent integrity
11 checking of block devices using kernel crypto API.
12
13 The dm-verity devices are always read-only.
14
15 Veritysetup supports these operations:
16 .PP
17 \fIformat\fR <data_device> <hash_device>
18 .IP
19 Calculates and permanently stores hash verification data for data_device.
20 Hash area can be located on the same device after data if specified
21 by \-\-hash\-offset option.
22
23 Note you need to provide root hash string for device verification
24 or activation. Root hash must be trusted.
25
26 The data or hash device argument can be block device or file image.
27 If hash device path doesn't exist, it will be created as file.
28
29 \fB<options>\fR can be [\-\-hash, \-\-no-superblock, \-\-format,
30 \-\-data-block-size, \-\-hash-block-size, \-\-data-blocks, \-\-hash-offset,
31 \-\-salt, \-\-uuid]
32 .PP
33 \fIopen\fR <data_device> <name> <hash_device> <root_hash>
34 .br
35 \fIcreate\fR <name> <data_device> <hash_device> <root_hash>  (\fBOBSOLETE syntax\fR)
36 .IP
37 Creates a mapping with <name> backed by device <data_device> and using
38 <hash_device> for in-kernel verification.
39
40 The <root_hash> is a hexadecimal string.
41
42 \fB<options>\fR can be [\-\-hash-offset, \-\-no-superblock,
43 \-\-ignore-corruption or \-\-restart-on-corruption, \-\-panic-on-corruption,
44 \-\-ignore-zero-blocks, \-\-check-at-most-once, \-\-root-hash-signature]
45
46 If option \-\-no-superblock is used, you have to use as the same options
47 as in initial format operation.
48 .PP
49 \fIverify\fR <data_device> <hash_device> <root_hash>
50 .IP
51 Verifies data on data_device with use of hash blocks stored on hash_device.
52
53 This command performs userspace verification, no kernel device is created.
54
55 The <root_hash> is a hexadecimal string.
56
57 \fB<options>\fR can be [\-\-hash-offset, \-\-no-superblock]
58
59 If option \-\-no-superblock is used, you have to use as the same options
60 as in initial format operation.
61 .PP
62 \fIclose\fR <name>
63 .IP
64 Removes existing mapping <name>.
65
66 For backward compatibility there is \fBremove\fR command alias
67 for \fBclose\fR command.
68 .PP
69 \fIstatus\fR <name>
70 .IP
71 Reports status for the active verity mapping <name>.
72 .PP
73 \fIdump\fR <hash_device>
74 .IP
75 Reports parameters of verity device from on-disk stored superblock.
76
77 \fB<options>\fR can be [\-\-no-superblock]
78 .SH OPTIONS
79 .TP
80 .B "\-\-verbose, \-v"
81 Print more information on command execution.
82 .TP
83 .B "\-\-debug"
84 Run in debug mode with full diagnostic logs. Debug output
85 lines are always prefixed by '#'.
86 .TP
87 .B "\-\-no-superblock"
88 Create or use dm-verity without permanent on-disk superblock.
89 .TP
90 .B "\-\-format=number"
91 Specifies the hash version type.
92 Format type 0 is original Chrome OS version. Format type 1 is current version.
93 .TP
94 .B "\-\-data-block-size=bytes"
95 Used block size for the data device.
96 (Note kernel supports only page-size as maximum here.)
97 .TP
98 .B "\-\-hash-block-size=bytes"
99 Used block size for the hash device.
100 (Note kernel supports only page-size as maximum here.)
101 .TP
102 .B "\-\-data-blocks=blocks"
103 Size of data device used in verification.
104 If not specified, the whole device is used.
105 .TP
106 .B "\-\-hash-offset=bytes"
107 Offset of hash area/superblock on hash_device.
108 Value must be aligned to disk sector offset.
109 .TP
110 .B "\-\-salt=hex string"
111 Salt used for format or verification.
112 Format is a hexadecimal string.
113 .TP
114 .B "\-\-uuid=UUID"
115 Use the provided UUID for format command instead of generating new one.
116
117 The UUID must be provided in standard UUID format,
118 e.g. 12345678-1234-1234-1234-123456789abc.
119 .TP
120 .B "\-\-ignore-corruption", "\-\-restart-on-corruption", "\-\-panic-on-corruption"
121 Defines what to do if data integrity problem is detected (data corruption).
122
123 Without these options kernel fails the IO operation with I/O error.
124 With \-\-ignore-corruption option the corruption is only logged.
125 With \-\-restart-on-corruption or  \-\-panic-on-corruption the kernel
126 is restarted (panicked) immediately.
127 (You have to provide way how to avoid restart loops.)
128
129 \fBWARNING:\fR Use these options only for very specific cases.
130 These options are available since Linux kernel version 4.1.
131 .TP
132 .B "\-\-ignore-zero-blocks"
133 Instruct kernel to not verify blocks that are expected to contain zeroes
134 and always directly return zeroes instead.
135
136 \fBWARNING:\fR Use this option only in very specific cases.
137 This option is available since Linux kernel version 4.5.
138 .TP
139 .B "\-\-check-at-most-once"
140 Instruct kernel to verify blocks only the first time they are read
141 from the data device, rather than every time.
142
143 \fBWARNING:\fR It provides a reduced level of security because only
144 offline tampering of the data device's content will be detected,
145 not online tampering.
146 This option is available since Linux kernel version 4.17.
147 .TP
148 .B "\-\-hash=hash"
149 Hash algorithm for dm-verity. For default see \-\-help option.
150 .TP
151 .B "\-\-version"
152 Show the program version.
153 .TP
154 .B "\-\-fec-device=fec_device"
155 Use forward error correction (FEC) to recover from corruption if hash verification fails.
156 Use encoding data from the specified device.
157
158 The fec device argument can be block device or file image.
159 For format, if fec device path doesn't exist, it will be created as file.
160
161 Block sizes for data and hash devices must match.
162 Also, if the verity data_device is encrypted the fec_device should be too.
163
164 FEC calculation covers data, hash area, and optional foreign metadata stored on the same
165 device with the hash tree (additional space after hash area).
166 Size of this optional additional area protected by FEC is calculated from image sizes,
167 so you must be sure that you use the same images for activation.
168
169 If the hash device is in a separate image, metadata covers the whole rest of the image after the hash area.
170
171 If hash and FEC device is in the image, metadata ends on the FEC area offset.
172
173 .TP
174 .B "\-\-fec-offset=bytes"
175 This is the offset, in bytes, from the start of the FEC device to the beginning of the encoding data.
176 .TP
177 .B "\-\-fec-roots=num"
178 Number of generator roots. This equals to the number of parity bytes in the encoding data.
179 In RS(M, N) encoding, the number of roots is M-N. M is 255 and M-N is between 2 and 24 (including).
180 .TP
181 .B "\-\-root-hash-signature=FILE"
182 Path to roothash signature file used to verify the root hash (in kernel).
183 This feature requires Linux kernel version 5.4 or more recent.
184 .TP
185 .SH RETURN CODES
186 Veritysetup returns 0 on success and a non-zero value on error.
187
188 Error codes are:
189     1 wrong parameters
190     2 no permission
191     3 out of memory
192     4 wrong device specified
193     5 device already exists or device is busy.
194
195 .SH EXAMPLES
196 .B "veritysetup \-\-data-blocks=256 format <data_device> <hash_device>"
197
198 Calculates and stores verification data on hash_device for the first 256 blocks (of block-size).
199 If hash_device does not exist, it is created (as file image).
200
201 .B "veritysetup format <data_device> <hash_device>"
202
203 Calculates and stores verification data on hash_device for the whole data_device.
204
205 .B "veritysetup \-\-data-blocks=256 \-\-hash-offset=1052672 format <device> <device>"
206
207 Verification data (hashes) is stored on the same device as data (starting at hash-offset).
208 Hash-offset must be greater than number of blocks in data-area.
209
210 .B "veritysetup \-\-data-blocks=256 \-\-hash-offset=1052672 create test-device <device> <device> <root_hash>"
211
212 Activates the verity device named test-device. Options \-\-data-blocks and \-\-hash-offset are the same
213 as in the format command. The <root_hash> was calculated in format command.
214
215 .B "veritysetup \-\-data-blocks=256 \-\-hash-offset=1052672 verify <data_device> <hash_device> <root_hash>"
216
217 Verifies device without activation (in userspace).
218
219 .B "veritysetup \-\-fec-device=<fec_device> \-\-fec-roots=10 format <data_device> <hash_device>"
220
221 Calculates and stores verification and encoding data for data_device.
222
223 .SH REPORTING BUGS
224 Report bugs, including ones in the documentation, on
225 the cryptsetup mailing list at <dm-crypt@saout.de>
226 or in the 'Issues' section on LUKS website.
227 Please attach the output of the failed command with the
228 \-\-debug option added.
229 .SH AUTHORS
230 The first implementation of veritysetup was written by Chrome OS authors.
231
232 This version is based on verification code written by Mikulas Patocka <mpatocka@redhat.com>
233 and rewritten for libcryptsetup by Milan Broz <gmazyland@gmail.com>.
234 .SH COPYRIGHT
235 Copyright \(co 2012-2021 Red Hat, Inc.
236 .br
237 Copyright \(co 2012-2021 Milan Broz
238
239 This is free software; see the source for copying conditions.  There is NO
240 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
241 .SH SEE ALSO
242 The project website at \fBhttps://gitlab.com/cryptsetup/cryptsetup\fR
243
244 The verity on-disk format specification available at
245 \fBhttps://gitlab.com/cryptsetup/cryptsetup/wikis/DMVerity\fR