sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget4/translations/zh_CN/admin-guide/device-mapper/veritymodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget4/translations/zh_TW/admin-guide/device-mapper/veritymodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget4/translations/it_IT/admin-guide/device-mapper/veritymodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget4/translations/ja_JP/admin-guide/device-mapper/veritymodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget4/translations/ko_KR/admin-guide/device-mapper/veritymodnameN classnameN refexplicituh1hhh ubh)}(hhh]hPortuguese (Brazilian)}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget4/translations/pt_BR/admin-guide/device-mapper/veritymodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget4/translations/sp_SP/admin-guide/device-mapper/veritymodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(h dm-verityh]h dm-verity}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhN/var/lib/git/docbuild/linux/Documentation/admin-guide/device-mapper/verity.rsthKubh paragraph)}(hDevice-Mapper's "verity" target provides transparent integrity checking of block devices using a cryptographic digest provided by the kernel crypto API. This target is read-only.h]hDevice-Mapper’s “verity” target provides transparent integrity checking of block devices using a cryptographic digest provided by the kernel crypto API. This target is read-only.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hhh](h)}(hConstruction Parametersh]hConstruction Parameters}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhK ubh literal_block)}(h [<#opt_params> ]h]h [<#opt_params> ]}hhsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1hhhhKhhhhubhdefinition_list)}(hhh](hdefinition_list_item)}(hX This is the type of the on-disk hash format. 0 is the original format used in the Chromium OS. The salt is appended when hashing, digests are stored continuously and the rest of the block is padded with zeroes. 1 is the current format that should be used for new devices. The salt is prepended when hashing and each digest is padded with zeroes to the power of two. h](hterm)}(h h]h }(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1j hhhKhjubh definition)}(hhh](h)}(h,This is the type of the on-disk hash format.h]h,This is the type of the on-disk hash format.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hhh](j)}(h0 is the original format used in the Chromium OS. The salt is appended when hashing, digests are stored continuously and the rest of the block is padded with zeroes. h](j )}(h10 is the original format used in the Chromium OS.h]h10 is the original format used in the Chromium OS.}(hj3hhhNhNubah}(h]h ]h"]h$]h&]uh1j hhhKhj/ubj)}(hhh]h)}(hsThe salt is appended when hashing, digests are stored continuously and the rest of the block is padded with zeroes.h]hsThe salt is appended when hashing, digests are stored continuously and the rest of the block is padded with zeroes.}(hjDhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjAubah}(h]h ]h"]h$]h&]uh1jhj/ubeh}(h]h ]h"]h$]h&]uh1jhhhKhj,ubj)}(h1 is the current format that should be used for new devices. The salt is prepended when hashing and each digest is padded with zeroes to the power of two. h](j )}(h<1 is the current format that should be used for new devices.h]h<1 is the current format that should be used for new devices.}(hjbhhhNhNubah}(h]h ]h"]h$]h&]uh1j hhhKhj^ubj)}(hhh]h)}(h]The salt is prepended when hashing and each digest is padded with zeroes to the power of two.h]h]The salt is prepended when hashing and each digest is padded with zeroes to the power of two.}(hjshhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjpubah}(h]h ]h"]h$]h&]uh1jhj^ubeh}(h]h ]h"]h$]h&]uh1jhhhKhj,ubeh}(h]h ]h"]h$]h&]uh1hhjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKhjubj)}(h This is the device containing data, the integrity of which needs to be checked. It may be specified as a path, like /dev/sdaX, or a device number, :. h](j )}(hh]h}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j hhhK"hjubj)}(hhh]h)}(hThis is the device containing data, the integrity of which needs to be checked. It may be specified as a path, like /dev/sdaX, or a device number, :.h]hThis is the device containing data, the integrity of which needs to be checked. It may be specified as a path, like /dev/sdaX, or a device number, :.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhK"hjhhubj)}(h This is the device that supplies the hash tree data. It may be specified similarly to the device path and may be the same device. If the same device is used, the hash_start should be outside the configured dm-verity device. h](j )}(h h]h }(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j hhhK(hjubj)}(hhh]h)}(hThis is the device that supplies the hash tree data. It may be specified similarly to the device path and may be the same device. If the same device is used, the hash_start should be outside the configured dm-verity device.h]hThis is the device that supplies the hash tree data. It may be specified similarly to the device path and may be the same device. If the same device is used, the hash_start should be outside the configured dm-verity device.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK%hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhK(hjhhubj)}(hu The block size on a data device in bytes. Each block corresponds to one digest on the hash device. h](j )}(hh]h}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j hhhK,hjubj)}(hhh]h)}(hbThe block size on a data device in bytes. Each block corresponds to one digest on the hash device.h]hbThe block size on a data device in bytes. Each block corresponds to one digest on the hash device.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK+hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhK,hjhhubj)}(h5 The size of a hash block in bytes. h](j )}(hh]h}(hj0hhhNhNubah}(h]h ]h"]h$]h&]uh1j hhhK/hj,ubj)}(hhh]h)}(h"The size of a hash block in bytes.h]h"The size of a hash block in bytes.}(hjAhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK/hj>ubah}(h]h ]h"]h$]h&]uh1jhj,ubeh}(h]h ]h"]h$]h&]uh1jhhhK/hjhhubj)}(h The number of data blocks on the data device. Additional blocks are inaccessible. You can place hashes to the same partition as data, in this case hashes are placed after . h](j )}(hh]h}(hj_hhhNhNubah}(h]h ]h"]h$]h&]uh1j hhhK4hj[ubj)}(hhh]h)}(hThe number of data blocks on the data device. Additional blocks are inaccessible. You can place hashes to the same partition as data, in this case hashes are placed after .h]hThe number of data blocks on the data device. Additional blocks are inaccessible. You can place hashes to the same partition as data, in this case hashes are placed after .}(hjphhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK2hjmubah}(h]h ]h"]h$]h&]uh1jhj[ubeh}(h]h ]h"]h$]h&]uh1jhhhK4hjhhubj)}(h This is the offset, in -blocks, from the start of hash_dev to the root block of the hash tree. h](j )}(hh]h}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j hhhK8hjubj)}(hhh]h)}(hoThis is the offset, in -blocks, from the start of hash_dev to the root block of the hash tree.h]hoThis is the offset, in -blocks, from the start of hash_dev to the root block of the hash tree.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK7hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhK8hjhhubj)}(h{ The cryptographic hash algorithm used for this device. This should be the name of the algorithm, like "sha1". h](j )}(h h]h }(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j hhhK The hexadecimal encoding of the cryptographic hash of the root hash block and the salt. This hash should be trusted as there is no other authenticity beyond this point. h](j )}(hh]h}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j hhhKAhjubj)}(hhh]h)}(hThe hexadecimal encoding of the cryptographic hash of the root hash block and the salt. This hash should be trusted as there is no other authenticity beyond this point.h]hThe hexadecimal encoding of the cryptographic hash of the root hash block and the salt. This hash should be trusted as there is no other authenticity beyond this point.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK?hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKAhjhhubj)}(h3 The hexadecimal encoding of the salt value. h](j )}(hh]h}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j hhhKDhjubj)}(hhh]h)}(h+The hexadecimal encoding of the salt value.h]h+The hexadecimal encoding of the salt value.}(hj,hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKDhj)ubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKDhjhhubj)}(hX<#opt_params> Number of optional parameters. If there are no optional parameters, the optional parameters section can be skipped or #opt_params can be zero. Otherwise #opt_params is the number of following arguments. Example of optional parameters section: 1 ignore_corruption h](j )}(h <#opt_params>h]h <#opt_params>}(hjJhhhNhNubah}(h]h ]h"]h$]h&]uh1j hhhKLhjFubj)}(hhh](h)}(hNumber of optional parameters. If there are no optional parameters, the optional parameters section can be skipped or #opt_params can be zero. Otherwise #opt_params is the number of following arguments.h]hNumber of optional parameters. If there are no optional parameters, the optional parameters section can be skipped or #opt_params can be zero. Otherwise #opt_params is the number of following arguments.}(hj[hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKGhjXubh)}(hhh]j)}(hhhhNhNubah}(h]h ]h"]h$]h&]uh1j hhhK\hj:ubj)}(hhh]h)}(htRestart the system when an I/O error is detected. This option can be combined with the restart_on_corruption option.h]htRestart the system when an I/O error is detected. This option can be combined with the restart_on_corruption option.}(hjOhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK[hjLubah}(h]h ]h"]h$]h&]uh1jhj:ubeh}(h]h ]h"]h$]h&]uh1jhhhK\hjhhubj)}(hpanic_on_error Panic the device when an I/O error is detected. This option is not compatible with the restart_on_error option but can be combined with the panic_on_corruption option. h](j )}(hpanic_on_errorh]hpanic_on_error}(hjmhhhNhNubah}(h]h ]h"]h$]h&]uh1j hhhKahjiubj)}(hhh]h)}(hPanic the device when an I/O error is detected. This option is not compatible with the restart_on_error option but can be combined with the panic_on_corruption option.h]hPanic the device when an I/O error is detected. This option is not compatible with the restart_on_error option but can be combined with the panic_on_corruption option.}(hj~hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK_hj{ubah}(h]h ]h"]h$]h&]uh1jhjiubeh}(h]h ]h"]h$]h&]uh1jhhhKahjhhubj)}(hignore_zero_blocks Do not verify blocks that are expected to contain zeroes and always return zeroes instead. This may be useful if the partition contains unused blocks that are not guaranteed to contain zeroes. h](j )}(hignore_zero_blocksh]hignore_zero_blocks}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j hhhKfhjubj)}(hhh]h)}(hDo not verify blocks that are expected to contain zeroes and always return zeroes instead. This may be useful if the partition contains unused blocks that are not guaranteed to contain zeroes.h]hDo not verify blocks that are expected to contain zeroes and always return zeroes instead. This may be useful if the partition contains unused blocks that are not guaranteed to contain zeroes.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKdhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKfhjhhubj)}(hXuse_fec_from_device Use forward error correction (FEC) parity data from the specified device to try to automatically recover from corruption and I/O errors. If this option is given, then and must also be given. must also be equal to . can be the same as , in which case must be outside the data area. It can also be the same as , in which case must be outside the hash and optional additional metadata areas. If the data is encrypted, the should be too. For more information, see `Forward error correction`_. h](j )}(huse_fec_from_device h]huse_fec_from_device }(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j hhhKuhjubj)}(hhh](h)}(hUse forward error correction (FEC) parity data from the specified device to try to automatically recover from corruption and I/O errors.h]hUse forward error correction (FEC) parity data from the specified device to try to automatically recover from corruption and I/O errors.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKihjubh)}(hIf this option is given, then and must also be given. must also be equal to .h]hIf this option is given, then and must also be given. must also be equal to .}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKlhjubh)}(h can be the same as , in which case must be outside the data area. It can also be the same as , in which case must be outside the hash and optional additional metadata areas.h]h can be the same as , in which case must be outside the data area. It can also be the same as , in which case must be outside the hash and optional additional metadata areas.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKohjubh)}(h is encrypted, the should be too.h]h is encrypted, the should be too.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKshjubh)}(h6For more information, see `Forward error correction`_.h](hFor more information, see }(hjhhhNhNubh reference)}(h`Forward error correction`_h]hForward error correction}(hjhhhNhNubah}(h]h ]h"]h$]h&]nameForward error correctionrefidforward-error-correctionuh1jhjresolvedKubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKuhjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKuhjhhubj)}(hXfec_roots The number of parity bytes in each 255-byte Reed-Solomon codeword. The Reed-Solomon code used will be an RS(255, k) code where k = 255 - fec_roots. The supported values are 2 through 24 inclusive. Higher values provide stronger error correction. However, the minimum value of 2 already provides strong error correction due to the use of interleaving, so 2 is the recommended value for most users. fec_roots=2 corresponds to an RS(255, 253) code, which has a space overhead of about 0.8%. h](j )}(hfec_roots h]hfec_roots }(hjKhhhNhNubah}(h]h ]h"]h$]h&]uh1j hhhKhjGubj)}(hhh](h)}(hThe number of parity bytes in each 255-byte Reed-Solomon codeword. The Reed-Solomon code used will be an RS(255, k) code where k = 255 - fec_roots.h]hThe number of parity bytes in each 255-byte Reed-Solomon codeword. The Reed-Solomon code used will be an RS(255, k) code where k = 255 - fec_roots.}(hj\hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKxhjYubh)}(hXVThe supported values are 2 through 24 inclusive. Higher values provide stronger error correction. However, the minimum value of 2 already provides strong error correction due to the use of interleaving, so 2 is the recommended value for most users. fec_roots=2 corresponds to an RS(255, 253) code, which has a space overhead of about 0.8%.h]hXVThe supported values are 2 through 24 inclusive. Higher values provide stronger error correction. However, the minimum value of 2 already provides strong error correction due to the use of interleaving, so 2 is the recommended value for most users. fec_roots=2 corresponds to an RS(255, 253) code, which has a space overhead of about 0.8%.}(hjjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK{hjYubeh}(h]h ]h"]h$]h&]uh1jhjGubeh}(h]h ]h"]h$]h&]uh1jhhhKhjhhubj)}(hXfec_blocks The total number of blocks that are error-checked using FEC. This must be at least the sum of and the number of blocks needed by the hash tree. It can include additional metadata blocks, which are assumed to be accessible on following the hash blocks. Note that this is *not* the number of parity blocks. The number of parity blocks is inferred from , , and . h](j )}(hfec_blocks h]hfec_blocks }(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j hhhKhjubj)}(hhh](h)}(hX,The total number of blocks that are error-checked using FEC. This must be at least the sum of and the number of blocks needed by the hash tree. It can include additional metadata blocks, which are assumed to be accessible on following the hash blocks.h]hX,The total number of blocks that are error-checked using FEC. This must be at least the sum of and the number of blocks needed by the hash tree. It can include additional metadata blocks, which are assumed to be accessible on following the hash blocks.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hNote that this is *not* the number of parity blocks. The number of parity blocks is inferred from , , and .h](hNote that this is }(hjhhhNhNubhemphasis)}(h*not*h]hnot}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhjubh} the number of parity blocks. The number of parity blocks is inferred from , , and .}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKhjhhubj)}(hfec_start This is the offset, in blocks, from the start of to the beginning of the parity data. h](j )}(hfec_start h]hfec_start }(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j hhhKhjubj)}(hhh]h)}(hqThis is the offset, in blocks, from the start of to the beginning of the parity data.h]hqThis is the offset, in blocks, from the start of to the beginning of the parity data.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKhjhhubj)}(hXcheck_at_most_once Verify data blocks only the first time they are read from the data device, rather than every time. This reduces the overhead of dm-verity so that it can be used on systems that are memory and/or CPU constrained. However, it provides a reduced level of security because only offline tampering of the data device's content will be detected, not online tampering. Hash blocks are still verified each time they are read from the hash device, since verification of hash blocks is less performance critical than data blocks, and a hash block will not be verified any more after all the data blocks it covers have been verified anyway. h](j )}(hcheck_at_most_onceh]hcheck_at_most_once}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j hhhKhjubj)}(hhh](h)}(hXjVerify data blocks only the first time they are read from the data device, rather than every time. This reduces the overhead of dm-verity so that it can be used on systems that are memory and/or CPU constrained. However, it provides a reduced level of security because only offline tampering of the data device's content will be detected, not online tampering.h]hXlVerify data blocks only the first time they are read from the data device, rather than every time. This reduces the overhead of dm-verity so that it can be used on systems that are memory and/or CPU constrained. However, it provides a reduced level of security because only offline tampering of the data device’s content will be detected, not online tampering.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(hX Hash blocks are still verified each time they are read from the hash device, since verification of hash blocks is less performance critical than data blocks, and a hash block will not be verified any more after all the data blocks it covers have been verified anyway.h]hX Hash blocks are still verified each time they are read from the hash device, since verification of hash blocks is less performance critical than data blocks, and a hash block will not be verified any more after all the data blocks it covers have been verified anyway.}(hj'hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKhjhhubj)}(hXroot_hash_sig_key_desc This is the description of the USER_KEY that the kernel will lookup to get the pkcs7 signature of the roothash. The pkcs7 signature is used to validate the root hash during the creation of the device mapper block device. Verification of roothash depends on the config DM_VERITY_VERIFY_ROOTHASH_SIG being set in the kernel. The signatures are checked against the builtin trusted keyring by default, or the secondary trusted keyring if DM_VERITY_VERIFY_ROOTHASH_SIG_SECONDARY_KEYRING is set. The secondary trusted keyring includes by default the builtin trusted keyring, and it can also gain new certificates at run time if they are signed by a certificate already in the secondary trusted keyring. h](j )}(h(root_hash_sig_key_desc h]h(root_hash_sig_key_desc }(hjEhhhNhNubah}(h]h ]h"]h$]h&]uh1j hhhKhjAubj)}(hhh]h)}(hXThis is the description of the USER_KEY that the kernel will lookup to get the pkcs7 signature of the roothash. The pkcs7 signature is used to validate the root hash during the creation of the device mapper block device. Verification of roothash depends on the config DM_VERITY_VERIFY_ROOTHASH_SIG being set in the kernel. The signatures are checked against the builtin trusted keyring by default, or the secondary trusted keyring if DM_VERITY_VERIFY_ROOTHASH_SIG_SECONDARY_KEYRING is set. The secondary trusted keyring includes by default the builtin trusted keyring, and it can also gain new certificates at run time if they are signed by a certificate already in the secondary trusted keyring.h]hXThis is the description of the USER_KEY that the kernel will lookup to get the pkcs7 signature of the roothash. The pkcs7 signature is used to validate the root hash during the creation of the device mapper block device. Verification of roothash depends on the config DM_VERITY_VERIFY_ROOTHASH_SIG being set in the kernel. The signatures are checked against the builtin trusted keyring by default, or the secondary trusted keyring if DM_VERITY_VERIFY_ROOTHASH_SIG_SECONDARY_KEYRING is set. The secondary trusted keyring includes by default the builtin trusted keyring, and it can also gain new certificates at run time if they are signed by a certificate already in the secondary trusted keyring.}(hjVhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjSubah}(h]h ]h"]h$]h&]uh1jhjAubeh}(h]h ]h"]h$]h&]uh1jhhhKhjhhubj)}(hXtry_verify_in_tasklet If verity hashes are in cache and the IO size does not exceed the limit, verify data blocks in bottom half instead of workqueue. This option can reduce IO latency. The size limits can be configured via /sys/module/dm_verity/parameters/use_bh_bytes. The four parameters correspond to limits for IOPRIO_CLASS_NONE, IOPRIO_CLASS_RT, IOPRIO_CLASS_BE and IOPRIO_CLASS_IDLE in turn. For example: ,,, 4096,4096,4096,4096 h](j )}(htry_verify_in_taskleth]htry_verify_in_tasklet}(hjthhhNhNubah}(h]h ]h"]h$]h&]uh1j hhhKhjpubj)}(hhh]h)}(hXIf verity hashes are in cache and the IO size does not exceed the limit, verify data blocks in bottom half instead of workqueue. This option can reduce IO latency. The size limits can be configured via /sys/module/dm_verity/parameters/use_bh_bytes. The four parameters correspond to limits for IOPRIO_CLASS_NONE, IOPRIO_CLASS_RT, IOPRIO_CLASS_BE and IOPRIO_CLASS_IDLE in turn. For example: ,,, 4096,4096,4096,4096h]hXIf verity hashes are in cache and the IO size does not exceed the limit, verify data blocks in bottom half instead of workqueue. This option can reduce IO latency. The size limits can be configured via /sys/module/dm_verity/parameters/use_bh_bytes. The four parameters correspond to limits for IOPRIO_CLASS_NONE, IOPRIO_CLASS_RT, IOPRIO_CLASS_BE and IOPRIO_CLASS_IDLE in turn. For example: ,,, 4096,4096,4096,4096}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjpubeh}(h]h ]h"]h$]h&]uh1jhhhKhjhhubeh}(h]h ]h"]h$]h&]uh1hhhhhhNhNubeh}(h]construction-parametersah ]h"]construction parametersah$]h&]uh1hhhhhhhhK ubh)}(hhh](h)}(hTheory of operationh]hTheory of operation}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hdm-verity is meant to be set up as part of a verified boot path. This may be anything ranging from a boot using tboot or trustedgrub to just booting from a known-good device (like a USB drive or CD).h]hdm-verity is meant to be set up as part of a verified boot path. This may be anything ranging from a boot using tboot or trustedgrub to just booting from a known-good device (like a USB drive or CD).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hXWhen a dm-verity device is configured, it is expected that the caller has been authenticated in some way (cryptographic signatures, etc). After instantiation, all hashes will be verified on-demand during disk access. If they cannot be verified up to the root node of the tree, the root hash, then the I/O will fail. This should detect tampering with any data on the device and the hash data.h]hXWhen a dm-verity device is configured, it is expected that the caller has been authenticated in some way (cryptographic signatures, etc). After instantiation, all hashes will be verified on-demand during disk access. If they cannot be verified up to the root node of the tree, the root hash, then the I/O will fail. This should detect tampering with any data on the device and the hash data.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hCryptographic hashes are used to assert the integrity of the device on a per-block basis. This allows for a lightweight hash computation on first read into the page cache. Block hashes are stored linearly, aligned to the nearest block size.h]hCryptographic hashes are used to assert the integrity of the device on a per-block basis. This allows for a lightweight hash computation on first read into the page cache. Block hashes are stored linearly, aligned to the nearest block size.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hhh](h)}(h Hash Treeh]h Hash Tree}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hEach node in the tree is a cryptographic hash. If it is a leaf node, the hash of some data block on disk is calculated. If it is an intermediary node, the hash of a number of child nodes is calculated.h]hEach node in the tree is a cryptographic hash. If it is a leaf node, the hash of some data block on disk is calculated. If it is an intermediary node, the hash of a number of child nodes is calculated.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hXGEach entry in the tree is a collection of neighboring nodes that fit in one block. The number is determined based on block_size and the size of the selected cryptographic digest algorithm. The hashes are linearly-ordered in this entry and any unaligned trailing space is ignored but included when calculating the parent node.h]hXGEach entry in the tree is a collection of neighboring nodes that fit in one block. The number is determined based on block_size and the size of the selected cryptographic digest algorithm. The hashes are linearly-ordered in this entry and any unaligned trailing space is ignored but included when calculating the parent node.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hThe tree looks something like:h]hThe tree looks something like:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh block_quote)}(h4alg = sha256, num_blocks = 32768, block_size = 4096 h]h)}(h3alg = sha256, num_blocks = 32768, block_size = 4096h]h3alg = sha256, num_blocks = 32768, block_size = 4096}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj%ubah}(h]h ]h"]h$]h&]uh1j#hhhKhjhhubh)}(hX [ root ] / . . . \ [entry_0] [entry_1] / . . . \ . . . \ [entry_0_0] . . . [entry_0_127] . . . . [entry_1_127] / ... \ / . . . \ / \ blk_0 ... blk_127 blk_16256 blk_16383 blk_32640 . . . blk_32767h]hX [ root ] / . . . \ [entry_0] [entry_1] / . . . \ . . . \ [entry_0_0] . . . [entry_0_127] . . . . [entry_1_127] / ... \ / . . . \ / \ blk_0 ... blk_127 blk_16256 blk_16383 blk_32640 . . . blk_32767}hj=sbah}(h]h ]h"]h$]h&]hhuh1hhhhKhjhhubeh}(h] hash-treeah ]h"] hash treeah$]h&]uh1hhjhhhhhKubh)}(hhh](h)}(hForward error correctionh]hForward error correction}(hjVhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjShhhhhKubh)}(hdm-verity's optional forward error correction (FEC) support adds strong error correction capabilities to dm-verity. It allows systems that would be rendered inoperable by errors to continue operating, albeit with reduced performance.h]hdm-verity’s optional forward error correction (FEC) support adds strong error correction capabilities to dm-verity. It allows systems that would be rendered inoperable by errors to continue operating, albeit with reduced performance.}(hjdhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjShhubh)}(hFEC uses Reed-Solomon (RS) codes that are interleaved across the entire device(s), allowing long bursts of corrupt or unreadable blocks to be recovered.h]hFEC uses Reed-Solomon (RS) codes that are interleaved across the entire device(s), allowing long bursts of corrupt or unreadable blocks to be recovered.}(hjrhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjShhubh)}(hdm-verity validates any FEC-corrected block against the wanted hash before using it. Therefore, FEC doesn't affect the security properties of dm-verity.h]hdm-verity validates any FEC-corrected block against the wanted hash before using it. Therefore, FEC doesn’t affect the security properties of dm-verity.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjShhubh)}(hkThe integration of FEC with dm-verity provides significant benefits over a separate error correction layer:h]hkThe integration of FEC with dm-verity provides significant benefits over a separate error correction layer:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjShhubh bullet_list)}(hhh](h list_item)}(hdm-verity invokes FEC only when a block's hash doesn't match the wanted hash or the block cannot be read at all. As a result, FEC doesn't add overhead to the common case where no error occurs. h]h)}(hdm-verity invokes FEC only when a block's hash doesn't match the wanted hash or the block cannot be read at all. As a result, FEC doesn't add overhead to the common case where no error occurs.h]hdm-verity invokes FEC only when a block’s hash doesn’t match the wanted hash or the block cannot be read at all. As a result, FEC doesn’t add overhead to the common case where no error occurs.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(h{dm-verity hashes are also used to identify erasure locations for RS decoding. This allows correcting twice as many errors. h]h)}(hzdm-verity hashes are also used to identify erasure locations for RS decoding. This allows correcting twice as many errors.h]hzdm-verity hashes are also used to identify erasure locations for RS decoding. This allows correcting twice as many errors.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubeh}(h]h ]h"]h$]h&]bullet-uh1jhhhKhjShhubh)}(hXzFEC uses an RS(255, k) code where k = 255 - fec_roots. fec_roots is usually 2. This means that each k (usually 253) message bytes have fec_roots (usually 2) bytes of parity data added to get a 255-byte codeword. (Many external sources call RS codewords "blocks". Since dm-verity already uses the term "block" to mean something else, we'll use the clearer term "RS codeword".)h]hXFEC uses an RS(255, k) code where k = 255 - fec_roots. fec_roots is usually 2. This means that each k (usually 253) message bytes have fec_roots (usually 2) bytes of parity data added to get a 255-byte codeword. (Many external sources call RS codewords “blocks”. Since dm-verity already uses the term “block” to mean something else, we’ll use the clearer term “RS codeword”.)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjShhubh)}(hEFEC checks fec_blocks blocks of message data in total, consisting of:h]hEFEC checks fec_blocks blocks of message data in total, consisting of:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjShhubhenumerated_list)}(hhh](j)}(h$The data blocks from the data deviceh]h)}(hjh]h$The data blocks from the data device}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(h$The hash blocks from the hash deviceh]h)}(hjh]h$The hash blocks from the hash device}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(hMOptional additional metadata that follows the hash blocks on the hash device h]h)}(hLOptional additional metadata that follows the hash blocks on the hash deviceh]hLOptional additional metadata that follows the hash blocks on the hash device}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj*ubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubeh}(h]h ]h"]h$]h&]enumtypearabicprefixhsuffix.uh1jhjShhhhhKubh)}(hddm-verity assumes that the FEC parity data was computed as if the following procedure were followed:h]hddm-verity assumes that the FEC parity data was computed as if the following procedure were followed:}(hjMhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjShhubj)}(hhh](j)}(h4Concatenate the message data from the above sources.h]h)}(hj`h]h4Concatenate the message data from the above sources.}(hjbhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj^ubah}(h]h ]h"]h$]h&]uh1jhj[hhhhhNubj)}(hpZero-pad to the next multiple of k blocks. Let msg be the resulting byte array, and msglen its length in bytes.h]h)}(hpZero-pad to the next multiple of k blocks. Let msg be the resulting byte array, and msglen its length in bytes.h]hpZero-pad to the next multiple of k blocks. Let msg be the resulting byte array, and msglen its length in bytes.}(hjyhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjuubah}(h]h ]h"]h$]h&]uh1jhj[hhhhhNubj)}(hX%For 0 <= i < msglen / k (for each RS codeword): a. Select msg[i + j * msglen / k] for 0 <= j < k. Consider these to be the 'k' message bytes of an RS codeword. b. Compute the corresponding 'fec_roots' parity bytes of the RS codeword, and concatenate them to the FEC parity data. h]h)}(hhh]j)}(hXFor 0 <= i < msglen / k (for each RS codeword): a. Select msg[i + j * msglen / k] for 0 <= j < k. Consider these to be the 'k' message bytes of an RS codeword. b. Compute the corresponding 'fec_roots' parity bytes of the RS codeword, and concatenate them to the FEC parity data. h](j )}(h/For 0 <= i < msglen / k (for each RS codeword):h]h/For 0 <= i < msglen / k (for each RS codeword):}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j hhhM hjubj)}(hhh]j)}(hhh](j)}(hlSelect msg[i + j * msglen / k] for 0 <= j < k. Consider these to be the 'k' message bytes of an RS codeword.h]h)}(hlSelect msg[i + j * msglen / k] for 0 <= j < k. Consider these to be the 'k' message bytes of an RS codeword.h]hpSelect msg[i + j * msglen / k] for 0 <= j < k. Consider these to be the ‘k’ message bytes of an RS codeword.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(htCompute the corresponding 'fec_roots' parity bytes of the RS codeword, and concatenate them to the FEC parity data. h]h)}(hsCompute the corresponding 'fec_roots' parity bytes of the RS codeword, and concatenate them to the FEC parity data.h]hwCompute the corresponding ‘fec_roots’ parity bytes of the RS codeword, and concatenate them to the FEC parity data.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]jH loweralphajJhjKjLuh1jhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhM hjubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]uh1jhj[hhhNhNubeh}(h]h ]h"]h$]h&]jHjIjJhjKjLuh1jhjShhhhhMubh)}(hXStep 3a interleaves the RS codewords across the entire device using an interleaving degree of data_block_size * ceil(fec_blocks / k). This is the maximal interleaving, such that the message data consists of a region containing byte 0 of all the RS codewords, then a region containing byte 1 of all the RS codewords, and so on up to the region for byte 'k - 1'. Note that the number of codewords is set to a multiple of data_block_size; thus, the regions are block-aligned, and there is an implicit zero padding of up to 'k - 1' blocks.h]hX!Step 3a interleaves the RS codewords across the entire device using an interleaving degree of data_block_size * ceil(fec_blocks / k). This is the maximal interleaving, such that the message data consists of a region containing byte 0 of all the RS codewords, then a region containing byte 1 of all the RS codewords, and so on up to the region for byte ‘k - 1’. Note that the number of codewords is set to a multiple of data_block_size; thus, the regions are block-aligned, and there is an implicit zero padding of up to ‘k - 1’ blocks.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjShhubh)}(hThis interleaving allows long bursts of errors to be corrected. It provides much stronger error correction than storage devices typically provide, while keeping the space overhead low.h]hThis interleaving allows long bursts of errors to be corrected. It provides much stronger error correction than storage devices typically provide, while keeping the space overhead low.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjShhubh)}(hThe cost is slow decoding: correcting a single block usually requires reading 254 extra blocks spread evenly across the device(s). However, that is acceptable because dm-verity uses FEC only when there is actually an error.h]hThe cost is slow decoding: correcting a single block usually requires reading 254 extra blocks spread evenly across the device(s). However, that is acceptable because dm-verity uses FEC only when there is actually an error.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjShhubh)}(hThe list below contains additional details about the RS codes used by dm-verity's FEC. Userspace programs that generate the parity data need to use these parameters for the parity data to match exactly:h]hThe list below contains additional details about the RS codes used by dm-verity’s FEC. Userspace programs that generate the parity data need to use these parameters for the parity data to match exactly:}(hj+ hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjShhubj)}(hhh](j)}(hField used is GF(256)h]h)}(hj> h]hField used is GF(256)}(hj@ hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM"hj< ubah}(h]h ]h"]h$]h&]uh1jhj9 hhhhhNubj)}(hBytes are mapped to/from GF(256) elements in the natural way, where bits 0 through 7 (low-order to high-order) map to the coefficients of x^0 through x^7h]h)}(hBytes are mapped to/from GF(256) elements in the natural way, where bits 0 through 7 (low-order to high-order) map to the coefficients of x^0 through x^7h]hBytes are mapped to/from GF(256) elements in the natural way, where bits 0 through 7 (low-order to high-order) map to the coefficients of x^0 through x^7}(hjW hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM#hjS ubah}(h]h ]h"]h$]h&]uh1jhj9 hhhhhNubj)}(h7Field generator polynomial is x^8 + x^4 + x^3 + x^2 + 1h]h)}(hjm h]h7Field generator polynomial is x^8 + x^4 + x^3 + x^2 + 1}(hjo hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM%hjk ubah}(h]h ]h"]h$]h&]uh1jhj9 hhhhhNubj)}(h-The codes used are systematic, BCH-view codesh]h)}(hj h]h-The codes used are systematic, BCH-view codes}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM&hj ubah}(h]h ]h"]h$]h&]uh1jhj9 hhhhhNubj)}(hPrimitive element alpha is 'x'h]h)}(hj h]h"Primitive element alpha is ‘x’}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM'hj ubah}(h]h ]h"]h$]h&]uh1jhj9 hhhhhNubj)}(h=First consecutive root of code generator polynomial is 'x^0' h]h)}(h