~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/admin-guide/device-mapper/dm-integrity.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/admin-guide/device-mapper/dm-integrity.rst (Version linux-6.12-rc7) and /Documentation/admin-guide/device-mapper/dm-integrity.rst (Version linux-5.11.22)


  1 ============                                        1 ============
  2 dm-integrity                                        2 dm-integrity
  3 ============                                        3 ============
  4                                                     4 
  5 The dm-integrity target emulates a block devic      5 The dm-integrity target emulates a block device that has additional
  6 per-sector tags that can be used for storing i      6 per-sector tags that can be used for storing integrity information.
  7                                                     7 
  8 A general problem with storing integrity tags       8 A general problem with storing integrity tags with every sector is that
  9 writing the sector and the integrity tag must       9 writing the sector and the integrity tag must be atomic - i.e. in case of
 10 crash, either both sector and integrity tag or     10 crash, either both sector and integrity tag or none of them is written.
 11                                                    11 
 12 To guarantee write atomicity, the dm-integrity     12 To guarantee write atomicity, the dm-integrity target uses journal, it
 13 writes sector data and integrity tags into a j     13 writes sector data and integrity tags into a journal, commits the journal
 14 and then copies the data and integrity tags to     14 and then copies the data and integrity tags to their respective location.
 15                                                    15 
 16 The dm-integrity target can be used with the d     16 The dm-integrity target can be used with the dm-crypt target - in this
 17 situation the dm-crypt target creates the inte     17 situation the dm-crypt target creates the integrity data and passes them
 18 to the dm-integrity target via bio_integrity_p     18 to the dm-integrity target via bio_integrity_payload attached to the bio.
 19 In this mode, the dm-crypt and dm-integrity ta     19 In this mode, the dm-crypt and dm-integrity targets provide authenticated
 20 disk encryption - if the attacker modifies the     20 disk encryption - if the attacker modifies the encrypted device, an I/O
 21 error is returned instead of random data.          21 error is returned instead of random data.
 22                                                    22 
 23 The dm-integrity target can also be used as a      23 The dm-integrity target can also be used as a standalone target, in this
 24 mode it calculates and verifies the integrity      24 mode it calculates and verifies the integrity tag internally. In this
 25 mode, the dm-integrity target can be used to d     25 mode, the dm-integrity target can be used to detect silent data
 26 corruption on the disk or in the I/O path.         26 corruption on the disk or in the I/O path.
 27                                                    27 
 28 There's an alternate mode of operation where d !!  28 There's an alternate mode of operation where dm-integrity uses bitmap
 29 instead of a journal. If a bit in the bitmap i     29 instead of a journal. If a bit in the bitmap is 1, the corresponding
 30 region's data and integrity tags are not synch     30 region's data and integrity tags are not synchronized - if the machine
 31 crashes, the unsynchronized regions will be re     31 crashes, the unsynchronized regions will be recalculated. The bitmap mode
 32 is faster than the journal mode, because we do     32 is faster than the journal mode, because we don't have to write the data
 33 twice, but it is also less reliable, because i     33 twice, but it is also less reliable, because if data corruption happens
 34 when the machine crashes, it may not be detect     34 when the machine crashes, it may not be detected.
 35                                                    35 
 36 When loading the target for the first time, th     36 When loading the target for the first time, the kernel driver will format
 37 the device. But it will only format the device     37 the device. But it will only format the device if the superblock contains
 38 zeroes. If the superblock is neither valid nor     38 zeroes. If the superblock is neither valid nor zeroed, the dm-integrity
 39 target can't be loaded.                            39 target can't be loaded.
 40                                                    40 
 41 Accesses to the on-disk metadata area containi << 
 42 buffered using dm-bufio. When an access to any << 
 43 occurs, each unique metadata area gets its own << 
 44 is capped at the size of the metadata area, bu << 
 45 requiring multiple buffers to represent the fu << 
 46 buffer size will produce a smaller resulting r << 
 47 metadata area for small reads/writes. The meta << 
 48 a full write to the data covered by a single b << 
 49                                                << 
 50 To use the target for the first time:              41 To use the target for the first time:
 51                                                    42 
 52 1. overwrite the superblock with zeroes            43 1. overwrite the superblock with zeroes
 53 2. load the dm-integrity target with one-secto     44 2. load the dm-integrity target with one-sector size, the kernel driver
 54    will format the device                          45    will format the device
 55 3. unload the dm-integrity target                  46 3. unload the dm-integrity target
 56 4. read the "provided_data_sectors" value from     47 4. read the "provided_data_sectors" value from the superblock
 57 5. load the dm-integrity target with the targe     48 5. load the dm-integrity target with the target size
 58    "provided_data_sectors"                         49    "provided_data_sectors"
 59 6. if you want to use dm-integrity with dm-cry     50 6. if you want to use dm-integrity with dm-crypt, load the dm-crypt target
 60    with the size "provided_data_sectors"           51    with the size "provided_data_sectors"
 61                                                    52 
 62                                                    53 
 63 Target arguments:                                  54 Target arguments:
 64                                                    55 
 65 1. the underlying block device                     56 1. the underlying block device
 66                                                    57 
 67 2. the number of reserved sector at the beginn     58 2. the number of reserved sector at the beginning of the device - the
 68    dm-integrity won't read of write these sect     59    dm-integrity won't read of write these sectors
 69                                                    60 
 70 3. the size of the integrity tag (if "-" is us     61 3. the size of the integrity tag (if "-" is used, the size is taken from
 71    the internal-hash algorithm)                    62    the internal-hash algorithm)
 72                                                    63 
 73 4. mode:                                           64 4. mode:
 74                                                    65 
 75         D - direct writes (without journal)        66         D - direct writes (without journal)
 76                 in this mode, journaling is        67                 in this mode, journaling is
 77                 not used and data sectors and      68                 not used and data sectors and integrity tags are written
 78                 separately. In case of crash,      69                 separately. In case of crash, it is possible that the data
 79                 and integrity tag doesn't matc     70                 and integrity tag doesn't match.
 80         J - journaled writes                       71         J - journaled writes
 81                 data and integrity tags are wr     72                 data and integrity tags are written to the
 82                 journal and atomicity is guara     73                 journal and atomicity is guaranteed. In case of crash,
 83                 either both data and tag or no     74                 either both data and tag or none of them are written. The
 84                 journaled mode degrades write      75                 journaled mode degrades write throughput twice because the
 85                 data have to be written twice.     76                 data have to be written twice.
 86         B - bitmap mode - data and metadata ar     77         B - bitmap mode - data and metadata are written without any
 87                 synchronization, the driver ma     78                 synchronization, the driver maintains a bitmap of dirty
 88                 regions where data and metadat     79                 regions where data and metadata don't match. This mode can
 89                 only be used with internal has     80                 only be used with internal hash.
 90         R - recovery mode - in this mode, jour     81         R - recovery mode - in this mode, journal is not replayed,
 91                 checksums are not checked and      82                 checksums are not checked and writes to the device are not
 92                 allowed. This mode is useful f     83                 allowed. This mode is useful for data recovery if the
 93                 device cannot be activated in      84                 device cannot be activated in any of the other standard
 94                 modes.                             85                 modes.
 95                                                    86 
 96 5. the number of additional arguments              87 5. the number of additional arguments
 97                                                    88 
 98 Additional arguments:                              89 Additional arguments:
 99                                                    90 
100 journal_sectors:number                             91 journal_sectors:number
101         The size of journal, this argument is      92         The size of journal, this argument is used only if formatting the
102         device. If the device is already forma     93         device. If the device is already formatted, the value from the
103         superblock is used.                        94         superblock is used.
104                                                    95 
105 interleave_sectors:number (default 32768)      !!  96 interleave_sectors:number
106         The number of interleaved sectors. Thi     97         The number of interleaved sectors. This values is rounded down to
107         a power of two. If the device is alrea     98         a power of two. If the device is already formatted, the value from
108         the superblock is used.                    99         the superblock is used.
109                                                   100 
110 meta_device:device                                101 meta_device:device
111         Don't interleave the data and metadata    102         Don't interleave the data and metadata on the device. Use a
112         separate device for metadata.             103         separate device for metadata.
113                                                   104 
114 buffer_sectors:number (default 128)            !! 105 buffer_sectors:number
115         The number of sectors in one metadata  !! 106         The number of sectors in one buffer. The value is rounded down to
116         down to a power of two.                !! 107         a power of two.
                                                   >> 108 
                                                   >> 109         The tag area is accessed using buffers, the buffer size is
                                                   >> 110         configurable. The large buffer size means that the I/O size will
                                                   >> 111         be larger, but there could be less I/Os issued.
117                                                   112 
118 journal_watermark:number (default 50)          !! 113 journal_watermark:number
119         The journal watermark in percents. Whe    114         The journal watermark in percents. When the size of the journal
120         exceeds this watermark, the thread tha    115         exceeds this watermark, the thread that flushes the journal will
121         be started.                               116         be started.
122                                                   117 
123 commit_time:number (default 10000)             !! 118 commit_time:number
124         Commit time in milliseconds. When this    119         Commit time in milliseconds. When this time passes, the journal is
125         written. The journal is also written i    120         written. The journal is also written immediately if the FLUSH
126         request is received.                      121         request is received.
127                                                   122 
128 internal_hash:algorithm(:key)   (the key is op    123 internal_hash:algorithm(:key)   (the key is optional)
129         Use internal hash or crc.                 124         Use internal hash or crc.
130         When this argument is used, the dm-int    125         When this argument is used, the dm-integrity target won't accept
131         integrity tags from the upper target,     126         integrity tags from the upper target, but it will automatically
132         generate and verify the integrity tags    127         generate and verify the integrity tags.
133                                                   128 
134         You can use a crc algorithm (such as c    129         You can use a crc algorithm (such as crc32), then integrity target
135         will protect the data against accident    130         will protect the data against accidental corruption.
136         You can also use a hmac algorithm (for    131         You can also use a hmac algorithm (for example
137         "hmac(sha256):0123456789abcdef"), in t    132         "hmac(sha256):0123456789abcdef"), in this mode it will provide
138         cryptographic authentication of the da    133         cryptographic authentication of the data without encryption.
139                                                   134 
140         When this argument is not used, the in    135         When this argument is not used, the integrity tags are accepted
141         from an upper layer target, such as dm    136         from an upper layer target, such as dm-crypt. The upper layer
142         target should check the validity of th    137         target should check the validity of the integrity tags.
143                                                   138 
144 recalculate                                       139 recalculate
145         Recalculate the integrity tags automat    140         Recalculate the integrity tags automatically. It is only valid
146         when using internal hash.                 141         when using internal hash.
147                                                   142 
148 journal_crypt:algorithm(:key)   (the key is op    143 journal_crypt:algorithm(:key)   (the key is optional)
149         Encrypt the journal using given algori    144         Encrypt the journal using given algorithm to make sure that the
150         attacker can't read the journal. You c    145         attacker can't read the journal. You can use a block cipher here
151         (such as "cbc(aes)") or a stream ciphe !! 146         (such as "cbc(aes)") or a stream cipher (for example "chacha20",
152         or "ctr(aes)").                        !! 147         "salsa20" or "ctr(aes)").
153                                                   148 
154         The journal contains history of last w    149         The journal contains history of last writes to the block device,
155         an attacker reading the journal could     150         an attacker reading the journal could see the last sector numbers
156         that were written. From the sector num    151         that were written. From the sector numbers, the attacker can infer
157         the size of files that were written. T    152         the size of files that were written. To protect against this
158         situation, you can encrypt the journal    153         situation, you can encrypt the journal.
159                                                   154 
160 journal_mac:algorithm(:key)     (the key is op    155 journal_mac:algorithm(:key)     (the key is optional)
161         Protect sector numbers in the journal     156         Protect sector numbers in the journal from accidental or malicious
162         modification. To protect against accid    157         modification. To protect against accidental modification, use a
163         crc algorithm, to protect against mali    158         crc algorithm, to protect against malicious modification, use a
164         hmac algorithm with a key.                159         hmac algorithm with a key.
165                                                   160 
166         This option is not needed when using i    161         This option is not needed when using internal-hash because in this
167         mode, the integrity of journal entries    162         mode, the integrity of journal entries is checked when replaying
168         the journal. Thus, modified sector num    163         the journal. Thus, modified sector number would be detected at
169         this stage.                               164         this stage.
170                                                   165 
171 block_size:number (default 512)                !! 166 block_size:number
172         The size of a data block in bytes. The !! 167         The size of a data block in bytes.  The larger the block size the
173         less overhead there is for per-block i    168         less overhead there is for per-block integrity metadata.
174         Supported values are 512, 1024, 2048 a !! 169         Supported values are 512, 1024, 2048 and 4096 bytes.  If not
                                                   >> 170         specified the default block size is 512 bytes.
175                                                   171 
176 sectors_per_bit:number                            172 sectors_per_bit:number
177         In the bitmap mode, this parameter spe    173         In the bitmap mode, this parameter specifies the number of
178         512-byte sectors that corresponds to o    174         512-byte sectors that corresponds to one bitmap bit.
179                                                   175 
180 bitmap_flush_interval:number                      176 bitmap_flush_interval:number
181         The bitmap flush interval in milliseco    177         The bitmap flush interval in milliseconds. The metadata buffers
182         are synchronized when this interval ex    178         are synchronized when this interval expires.
183                                                   179 
184 allow_discards                                    180 allow_discards
185         Allow block discard requests (a.k.a. T    181         Allow block discard requests (a.k.a. TRIM) for the integrity device.
186         Discards are only allowed to devices u    182         Discards are only allowed to devices using internal hash.
187                                                   183 
188 fix_padding                                       184 fix_padding
189         Use a smaller padding of the tag area     185         Use a smaller padding of the tag area that is more
190         space-efficient. If this option is not    186         space-efficient. If this option is not present, large padding is
191         used - that is for compatibility with     187         used - that is for compatibility with older kernels.
192                                                   188 
193 fix_hmac                                       << 
194         Improve security of internal_hash and  << 
195                                                << 
196         - the section number is mixed to the m << 
197           copy sectors from one journal sectio << 
198         - the superblock is protected by journ << 
199         - a 16-byte salt stored in the superbl << 
200           that the attacker can't detect that  << 
201           key and also to disallow the attacke << 
202           disk to another                      << 
203                                                << 
204 legacy_recalculate                                189 legacy_recalculate
205         Allow recalculating of volumes with HM    190         Allow recalculating of volumes with HMAC keys. This is disabled by
206         default for security reasons - an atta    191         default for security reasons - an attacker could modify the volume,
207         set recalc_sector to zero, and the ker    192         set recalc_sector to zero, and the kernel would not detect the
208         modification.                             193         modification.
209                                                   194 
210 The journal mode (D/J), buffer_sectors, journa    195 The journal mode (D/J), buffer_sectors, journal_watermark, commit_time and
211 allow_discards can be changed when reloading t    196 allow_discards can be changed when reloading the target (load an inactive
212 table and swap the tables with suspend and res    197 table and swap the tables with suspend and resume). The other arguments
213 should not be changed when reloading the targe    198 should not be changed when reloading the target because the layout of disk
214 data depend on them and the reloaded target wo    199 data depend on them and the reloaded target would be non-functional.
215                                                   200 
216 For example, on a device using the default int << 
217 block_size of 512, and an internal_hash of crc << 
218 bytes, it will take 128 KiB of tags to track a << 
219 256 sectors of metadata per data area. With th << 
220 128, that means there will be 2 buffers per me << 
221 per 16 MiB of data.                            << 
222                                                   201 
223 Status line:                                      202 Status line:
224                                                   203 
225 1. the number of integrity mismatches             204 1. the number of integrity mismatches
226 2. provided data sectors - that is the number     205 2. provided data sectors - that is the number of sectors that the user
227    could use                                      206    could use
228 3. the current recalculating position (or '-'     207 3. the current recalculating position (or '-' if we didn't recalculate)
229                                                   208 
230                                                   209 
231 The layout of the formatted block device:         210 The layout of the formatted block device:
232                                                   211 
233 * reserved sectors                                212 * reserved sectors
234     (they are not used by this target, they ca    213     (they are not used by this target, they can be used for
235     storing LUKS metadata or for other purpose    214     storing LUKS metadata or for other purpose), the size of the reserved
236     area is specified in the target arguments     215     area is specified in the target arguments
237                                                   216 
238 * superblock (4kiB)                               217 * superblock (4kiB)
239         * magic string - identifies that the d    218         * magic string - identifies that the device was formatted
240         * version                                 219         * version
241         * log2(interleave sectors)                220         * log2(interleave sectors)
242         * integrity tag size                      221         * integrity tag size
243         * the number of journal sections          222         * the number of journal sections
244         * provided data sectors - the number o    223         * provided data sectors - the number of sectors that this target
245           provides (i.e. the size of the devic    224           provides (i.e. the size of the device minus the size of all
246           metadata and padding). The user of t    225           metadata and padding). The user of this target should not send
247           bios that access data beyond the "pr    226           bios that access data beyond the "provided data sectors" limit.
248         * flags                                   227         * flags
249             SB_FLAG_HAVE_JOURNAL_MAC              228             SB_FLAG_HAVE_JOURNAL_MAC
250                 - a flag is set if journal_mac    229                 - a flag is set if journal_mac is used
251             SB_FLAG_RECALCULATING                 230             SB_FLAG_RECALCULATING
252                 - recalculating is in progress    231                 - recalculating is in progress
253             SB_FLAG_DIRTY_BITMAP                  232             SB_FLAG_DIRTY_BITMAP
254                 - journal area contains the bi    233                 - journal area contains the bitmap of dirty
255                   blocks                          234                   blocks
256         * log2(sectors per block)                 235         * log2(sectors per block)
257         * a position where recalculating finis    236         * a position where recalculating finished
258 * journal                                         237 * journal
259         The journal is divided into sections,     238         The journal is divided into sections, each section contains:
260                                                   239 
261         * metadata area (4kiB), it contains jo    240         * metadata area (4kiB), it contains journal entries
262                                                   241 
263           - every journal entry contains:         242           - every journal entry contains:
264                                                   243 
265                 * logical sector (specifies wh    244                 * logical sector (specifies where the data and tag should
266                   be written)                     245                   be written)
267                 * last 8 bytes of data            246                 * last 8 bytes of data
268                 * integrity tag (the size is s    247                 * integrity tag (the size is specified in the superblock)
269                                                   248 
270           - every metadata sector ends with       249           - every metadata sector ends with
271                                                   250 
272                 * mac (8-bytes), all the macs     251                 * mac (8-bytes), all the macs in 8 metadata sectors form a
273                   64-byte value. It is used to    252                   64-byte value. It is used to store hmac of sector
274                   numbers in the journal secti    253                   numbers in the journal section, to protect against a
275                   possibility that the attacke    254                   possibility that the attacker tampers with sector
276                   numbers in the journal.         255                   numbers in the journal.
277                 * commit id                       256                 * commit id
278                                                   257 
279         * data area (the size is variable; it     258         * data area (the size is variable; it depends on how many journal
280           entries fit into the metadata area)     259           entries fit into the metadata area)
281                                                   260 
282             - every sector in the data area co    261             - every sector in the data area contains:
283                                                   262 
284                 * data (504 bytes of data, the    263                 * data (504 bytes of data, the last 8 bytes are stored in
285                   the journal entry)              264                   the journal entry)
286                 * commit id                       265                 * commit id
287                                                   266 
288         To test if the whole journal section w    267         To test if the whole journal section was written correctly, every
289         512-byte sector of the journal ends wi    268         512-byte sector of the journal ends with 8-byte commit id. If the
290         commit id matches on all sectors in a     269         commit id matches on all sectors in a journal section, then it is
291         assumed that the section was written c    270         assumed that the section was written correctly. If the commit id
292         doesn't match, the section was written    271         doesn't match, the section was written partially and it should not
293         be replayed.                              272         be replayed.
294                                                   273 
295 * one or more runs of interleaved tags and dat    274 * one or more runs of interleaved tags and data.
296     Each run contains:                            275     Each run contains:
297                                                   276 
298         * tag area - it contains integrity tag    277         * tag area - it contains integrity tags. There is one tag for each
299           sector in the data area. The size of !! 278           sector in the data area
300           greater.                             << 
301         * data area - it contains data sectors    279         * data area - it contains data sectors. The number of data sectors
302           in one run must be a power of two. l    280           in one run must be a power of two. log2 of this value is stored
303           in the superblock.                      281           in the superblock.
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php