Imported Upstream version 2.3.3
[platform/upstream/cryptsetup.git] / man / veritysetup.8
1 .TH VERITYSETUP "8" "January 2019" "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, \-\-ignore-zero-blocks,
44 \-\-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"
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 the kernel is restarted immediately.
126 (You have to provide way how to avoid restart loops.)
127
128 \fBWARNING:\fR Use these options only for very specific cases.
129 These options are available since Linux kernel version 4.1.
130 .TP
131 .B "\-\-ignore-zero-blocks"
132 Instruct kernel to not verify blocks that are expected to contain zeroes
133 and always directly return zeroes instead.
134
135 \fBWARNING:\fR Use this option only in very specific cases.
136 This option is available since Linux kernel version 4.5.
137 .TP
138 .B "\-\-check-at-most-once"
139 Instruct kernel to verify blocks only the first time they are read
140 from the data device, rather than every time.
141
142 \fBWARNING:\fR It provides a reduced level of security because only
143 offline tampering of the data device's content will be detected,
144 not online tampering.
145 This option is available since Linux kernel version 4.17.
146 .TP
147 .B "\-\-hash=hash"
148 Hash algorithm for dm-verity. For default see \-\-help option.
149 .TP
150 .B "\-\-version"
151 Show the program version.
152 .TP
153 .B "\-\-fec-device=fec_device"
154 Use forward error correction (FEC) to recover from corruption if hash verification fails.
155 Use encoding data from the specified device.
156
157 The fec device argument can be block device or file image.
158 For format, if fec device path doesn't exist, it will be created as file.
159
160 Note: block sizes for data and hash devices must match. Also, if the verity data_device is encrypted the fec_device should be too.
161 .TP
162 .B "\-\-fec-offset=bytes"
163 This is the offset, in bytes, from the start of the FEC device to the beginning of the encoding data.
164 .TP
165 .B "\-\-fec-roots=num"
166 Number of generator roots. This equals to the number of parity bytes in the encoding data.
167 In RS(M, N) encoding, the number of roots is M-N. M is 255 and M-N is between 2 and 24 (including).
168 .TP
169 .B "\-\-root-hash-signature=FILE"
170 Path to roothash signature file used to verify the root hash (in kernel).
171 This feature requires Linux kernel version 5.4 or more recent.
172 .TP
173 .SH RETURN CODES
174 Veritysetup returns 0 on success and a non-zero value on error.
175
176 Error codes are:
177     1 wrong parameters
178     2 no permission
179     3 out of memory
180     4 wrong device specified
181     5 device already exists or device is busy.
182
183 .SH EXAMPLES
184 .B "veritysetup \-\-data-blocks=256 format <data_device> <hash_device>"
185
186 Calculates and stores verification data on hash_device for the first 256 blocks (of block-size).
187 If hash_device does not exist, it is created (as file image).
188
189 .B "veritysetup format <data_device> <hash_device>"
190
191 Calculates and stores verification data on hash_device for the whole data_device.
192
193 .B "veritysetup \-\-data-blocks=256 \-\-hash-offset=1052672 format <device> <device>"
194
195 Verification data (hashes) is stored on the same device as data (starting at hash-offset).
196 Hash-offset must be greater than number of blocks in data-area.
197
198 .B "veritysetup \-\-data-blocks=256 \-\-hash-offset=1052672 create test-device <device> <device> <root_hash>"
199
200 Activates the verity device named test-device. Options \-\-data-blocks and \-\-hash-offset are the same
201 as in the format command. The <root_hash> was calculated in format command.
202
203 .B "veritysetup \-\-data-blocks=256 \-\-hash-offset=1052672 verify <data_device> <hash_device> <root_hash>"
204
205 Verifies device without activation (in userspace).
206
207 .B "veritysetup \-\-fec-device=<fec_device> \-\-fec-roots=10 format <data_device> <hash_device>"
208
209 Calculates and stores verification and encoding data for data_device.
210
211 .SH REPORTING BUGS
212 Report bugs, including ones in the documentation, on
213 the cryptsetup mailing list at <dm-crypt@saout.de>
214 or in the 'Issues' section on LUKS website.
215 Please attach the output of the failed command with the
216 \-\-debug option added.
217 .SH AUTHORS
218 The first implementation of veritysetup was written by Chrome OS authors.
219
220 This version is based on verification code written by Mikulas Patocka <mpatocka@redhat.com>
221 and rewritten for libcryptsetup by Milan Broz <gmazyland@gmail.com>.
222 .SH COPYRIGHT
223 Copyright \(co 2012-2020 Red Hat, Inc.
224 .br
225 Copyright \(co 2012-2020 Milan Broz
226
227 This is free software; see the source for copying conditions.  There is NO
228 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
229 .SH SEE ALSO
230 The project website at \fBhttps://gitlab.com/cryptsetup/cryptsetup\fR
231
232 The verity on-disk format specification available at
233 \fBhttps://gitlab.com/cryptsetup/cryptsetup/wikis/DMVerity\fR