integritysetup recalculate does not work twice when changing hash
Issue description
integritysetup's recalculate flag doesn't seem to work twice, at least when changing the hash algorithm.
The first recalculation (with changed hash algorithm) seems to work well. Mounting the device with the new hash algorithm works fine afterwards, with no integrity issues. Applying another recalculation on the same device (again with a changed hash algorithm) doesn't seem to recalculate the integrity data again, as it directly throws integrity errors and re-opening the device with the 2nd changed set of hash algorithms fails with integrity errors as well.
I'm not sure whether this issues comes from integritysetup or the corresponding dm-integrity. Maybe the internal recalculated-until-here counter isn't reset when running it the second time?
Steps for reproducing the issue
- Setup a device with integritysetup using crc32c.
- Open the device with recalculating the integrity data using xxhash64.
- Open the device with recalculating the integrity data using crc32c (again). This shows integrity errors.
- Closing the device and opening it again with crc32c lists integrity errors again, whereas opening the device with xxhash64 looks fine (this step is omitted below).
More detailed steps, with the output below:
#!/bin/bash -x
integritysetup --version
uname -a
# Prepare image
dd if=/dev/zero of=img bs=10M count=1
losetup /dev/loop0 img
# Format and mount with crc32c
integritysetup format -B --debug --batch-mode --tag-size 4 --integrity crc32c --sector-size 512 /dev/loop0
integritysetup open -B --debug --integrity crc32c /dev/loop0 int-loop0
integritysetup dump --debug /dev/loop0
integritysetup status --debug /dev/mapper/int-loop0
dmsetup status --target integrity /dev/mapper/int-loop0
integritysetup close --debug /dev/mapper/int-loop0
# Recalculate with xxhash64
integritysetup open -B --debug --integrity xxhash64 --integrity-recalculate /dev/loop0 int-loop0
sleep 60s # Make sure everything got recalculated
integritysetup dump --debug /dev/loop0
integritysetup status --debug /dev/mapper/int-loop0
dmsetup status --target integrity /dev/mapper/int-loop0
integritysetup close --debug /dev/mapper/int-loop0
# Recalculate with crc32c
integritysetup open --debug -B --integrity crc32c --integrity-recalculate /dev/loop0 int-loop0
dmesg | tail | grep dm-
integritysetup dump --debug /dev/loop0
integritysetup status --debug /dev/mapper/int-loop0
dmsetup status --target integrity /dev/mapper/int-loop0
integritysetup close --debug /dev/mapper/int-loop0
# Cleanup
losetup -d /dev/loop0
rm img
Additional info
I could reproduce the issue with journal mod (-J), bitmap mode (-B), and direct mode (-D), so the journaling doesn't seem to be the issue.
Debug log
The output from the script above:
+ integritysetup --version
integritysetup 2.3.4
+ uname -a
Linux nibbler 5.10.0-3-amd64 #1 SMP Debian 5.10.13-1 (2021-02-06) x86_64 GNU/Linux
+ dd if=/dev/zero of=img bs=10M count=1
1+0 records in
1+0 records out
10485760 bytes (10 MB, 10 MiB) copied, 0.042495 s, 247 MB/s
+ losetup /dev/loop0 img
+ integritysetup format -B --debug --batch-mode --tag-size 4 --integrity crc32c --sector-size 512 /dev/loop0
# cryptsetup 2.3.4 processing "integritysetup format -B --debug --batch-mode --tag-size 4 --integrity crc32c --sector-size 512 /dev/loop0"
# Running command format.
# Allocating context for crypt device /dev/loop0.
# Trying to open and read device /dev/loop0 with direct-io.
# Initialising device-mapper backend library.
# Formatting device /dev/loop0 as type INTEGRITY.
# Crypto backend (OpenSSL 1.1.1d 10 Sep 2019) initialized in cryptsetup library version 2.3.4.
# Detected kernel Linux 5.10.0-3-amd64 x86_64.
# dm version [ opencount flush ] [16384] (*1)
# dm versions [ opencount flush ] [16384] (*1)
# Detected dm-ioctl version 4.43.0.
# Detected dm-crypt version 1.22.0.
# Detected dm-integrity version 1.6.0.
# Device-mapper backend running with UDEV support enabled.
# Trying to format INTEGRITY device on top of /dev/loop0, tmp name temporary-cryptsetup-c1f3eed9-0c1a-4d4c-94fb-c01ada2a1026, tag size 4.
# DM-UUID is CRYPT-INTEGRITY-temporary-cryptsetup-c1f3eed9-0c1a-4d4c-94fb-c01ada2a1026
# Udev cookie 0xd4db0d3 (semid 11) created
# Udev cookie 0xd4db0d3 (semid 11) incremented to 1
# Udev cookie 0xd4db0d3 (semid 11) incremented to 2
# Udev cookie 0xd4db0d3 (semid 11) assigned to CREATE task(0) with flags DISABLE_SUBSYSTEM_RULES DISABLE_DISK_RULES DISABLE_OTHER_RULES DISABLE_LIBRARY_FALLBACK (0x2e)
# dm create temporary-cryptsetup-c1f3eed9-0c1a-4d4c-94fb-c01ada2a1026 CRYPT-INTEGRITY-temporary-cryptsetup-c1f3eed9-0c1a-4d4c-94fb-c01ada2a1026 [ opencount flush ] [16384] (*1)
# dm reload temporary-cryptsetup-c1f3eed9-0c1a-4d4c-94fb-c01ada2a1026 [ opencount flush securedata ] [16384] (*1)
# dm resume temporary-cryptsetup-c1f3eed9-0c1a-4d4c-94fb-c01ada2a1026 [ opencount flush securedata ] [16384] (*1)
# temporary-cryptsetup-c1f3eed9-0c1a-4d4c-94fb-c01ada2a1026: Stacking NODE_ADD (254,38) 0:6 0660 [trust_udev]
# temporary-cryptsetup-c1f3eed9-0c1a-4d4c-94fb-c01ada2a1026: Stacking NODE_READ_AHEAD 256 (flags=1)
# Udev cookie 0xd4db0d3 (semid 11) decremented to 1
# Udev cookie 0xd4db0d3 (semid 11) waiting for zero
# Udev cookie 0xd4db0d3 (semid 11) destroyed
# temporary-cryptsetup-c1f3eed9-0c1a-4d4c-94fb-c01ada2a1026: Skipping NODE_ADD (254,38) 0:6 0660 [trust_udev]
# temporary-cryptsetup-c1f3eed9-0c1a-4d4c-94fb-c01ada2a1026: Processing NODE_READ_AHEAD 256 (flags=1)
# temporary-cryptsetup-c1f3eed9-0c1a-4d4c-94fb-c01ada2a1026 (254:38): read ahead is 256
# temporary-cryptsetup-c1f3eed9-0c1a-4d4c-94fb-c01ada2a1026: retaining kernel read ahead of 256 (requested 256)
# dm versions [ opencount flush ] [16384] (*1)
# Udev cookie 0xd4df6d6 (semid 12) created
# Udev cookie 0xd4df6d6 (semid 12) incremented to 1
# Udev cookie 0xd4df6d6 (semid 12) incremented to 2
# Udev cookie 0xd4df6d6 (semid 12) assigned to REMOVE task(2) with flags DISABLE_LIBRARY_FALLBACK (0x20)
# dm remove temporary-cryptsetup-c1f3eed9-0c1a-4d4c-94fb-c01ada2a1026 [ opencount flush retryremove ] [16384] (*1)
# Udev cookie 0xd4df6d6 (semid 12) decremented to 0
# Udev cookie 0xd4df6d6 (semid 12) waiting for zero
# Udev cookie 0xd4df6d6 (semid 12) destroyed
# Activating volume temporary-cryptsetup-2b20c71d-bb13-45a5-a05c-dcdddcd54a7d by volume key.
# dm versions [ opencount flush ] [16384] (*1)
# dm status temporary-cryptsetup-2b20c71d-bb13-45a5-a05c-dcdddcd54a7d [ opencount noflush ] [16384] (*1)
# Trying to activate INTEGRITY device on top of /dev/loop0, using name temporary-cryptsetup-2b20c71d-bb13-45a5-a05c-dcdddcd54a7d, tag size 4, provided sectors 20040.
# DM-UUID is CRYPT-INTEGRITY-temporary-cryptsetup-2b20c71d-bb13-45a5-a05c-dcdddcd54a7d
# Udev cookie 0xd4dd76e (semid 13) created
# Udev cookie 0xd4dd76e (semid 13) incremented to 1
# Udev cookie 0xd4dd76e (semid 13) incremented to 2
# Udev cookie 0xd4dd76e (semid 13) assigned to CREATE task(0) with flags DISABLE_SUBSYSTEM_RULES DISABLE_DISK_RULES DISABLE_OTHER_RULES DISABLE_LIBRARY_FALLBACK (0x2e)
# dm create temporary-cryptsetup-2b20c71d-bb13-45a5-a05c-dcdddcd54a7d CRYPT-INTEGRITY-temporary-cryptsetup-2b20c71d-bb13-45a5-a05c-dcdddcd54a7d [ opencount flush ] [16384] (*1)
# dm reload temporary-cryptsetup-2b20c71d-bb13-45a5-a05c-dcdddcd54a7d [ opencount flush securedata ] [16384] (*1)
# dm resume temporary-cryptsetup-2b20c71d-bb13-45a5-a05c-dcdddcd54a7d [ opencount flush securedata ] [16384] (*1)
# temporary-cryptsetup-2b20c71d-bb13-45a5-a05c-dcdddcd54a7d: Stacking NODE_ADD (254,38) 0:6 0660 [trust_udev]
# temporary-cryptsetup-2b20c71d-bb13-45a5-a05c-dcdddcd54a7d: Stacking NODE_READ_AHEAD 256 (flags=1)
# Udev cookie 0xd4dd76e (semid 13) decremented to 1
# Udev cookie 0xd4dd76e (semid 13) waiting for zero
# Udev cookie 0xd4dd76e (semid 13) destroyed
# temporary-cryptsetup-2b20c71d-bb13-45a5-a05c-dcdddcd54a7d: Skipping NODE_ADD (254,38) 0:6 0660 [trust_udev]
# temporary-cryptsetup-2b20c71d-bb13-45a5-a05c-dcdddcd54a7d: Processing NODE_READ_AHEAD 256 (flags=1)
# temporary-cryptsetup-2b20c71d-bb13-45a5-a05c-dcdddcd54a7d (254:38): read ahead is 256
# temporary-cryptsetup-2b20c71d-bb13-45a5-a05c-dcdddcd54a7d: retaining kernel read ahead of 256 (requested 256)
# Installing SIGINT/SIGTERM handler.
# Unblocking interruption on signal.
# Wipe [0] device /dev/mapper/temporary-cryptsetup-2b20c71d-bb13-45a5-a05c-dcdddcd54a7d, offset 0, length 0, block 1048576.
# Closing read write fd for /dev/mapper/temporary-cryptsetup-2b20c71d-bb13-45a5-a05c-dcdddcd54a7d.
# Deactivating volume temporary-cryptsetup-2b20c71d-bb13-45a5-a05c-dcdddcd54a7d.
# dm versions [ opencount flush ] [16384] (*1)
# dm status temporary-cryptsetup-2b20c71d-bb13-45a5-a05c-dcdddcd54a7d [ opencount noflush ] [16384] (*1)
# dm versions [ opencount flush ] [16384] (*1)
# dm table temporary-cryptsetup-2b20c71d-bb13-45a5-a05c-dcdddcd54a7d [ opencount flush securedata ] [16384] (*1)
# Trying to open and read device /dev/loop0 with direct-io.
# dm versions [ opencount flush ] [16384] (*1)
# Udev cookie 0xd4dd7d2 (semid 14) created
# Udev cookie 0xd4dd7d2 (semid 14) incremented to 1
# Udev cookie 0xd4dd7d2 (semid 14) incremented to 2
# Udev cookie 0xd4dd7d2 (semid 14) assigned to REMOVE task(2) with flags DISABLE_LIBRARY_FALLBACK (0x20)
# dm remove temporary-cryptsetup-2b20c71d-bb13-45a5-a05c-dcdddcd54a7d [ opencount flush retryremove ] [16384] (*1)
# Udev cookie 0xd4dd7d2 (semid 14) decremented to 0
# Udev cookie 0xd4dd7d2 (semid 14) waiting for zero
# Udev cookie 0xd4dd7d2 (semid 14) destroyed
# Unblocking interruption on signal.
# Releasing crypt device /dev/loop0 context.
# Releasing device-mapper backend.
# Closing read only fd for /dev/loop0.
# Closing read write fd for /dev/loop0.
Command successful.
+ integritysetup open -B --debug --integrity crc32c /dev/loop0 int-loop0
# cryptsetup 2.3.4 processing "integritysetup open -B --debug --integrity crc32c /dev/loop0 int-loop0"
# Running command open.
# Allocating context for crypt device /dev/loop0.
# Trying to open and read device /dev/loop0 with direct-io.
# Initialising device-mapper backend library.
# Trying to load INTEGRITY crypt type from device /dev/loop0.
# Crypto backend (OpenSSL 1.1.1d 10 Sep 2019) initialized in cryptsetup library version 2.3.4.
# Detected kernel Linux 5.10.0-3-amd64 x86_64.
# Activating volume int-loop0 by volume key.
# dm version [ opencount flush ] [16384] (*1)
# dm versions [ opencount flush ] [16384] (*1)
# Detected dm-ioctl version 4.43.0.
# Detected dm-crypt version 1.22.0.
# Detected dm-integrity version 1.6.0.
# Device-mapper backend running with UDEV support enabled.
# dm status int-loop0 [ opencount noflush ] [16384] (*1)
# Reusing open ro fd on device /dev/loop0
# Trying to activate INTEGRITY device on top of /dev/loop0, using name int-loop0, tag size 4, provided sectors 20040.
# DM-UUID is CRYPT-INTEGRITY-int-loop0
# Udev cookie 0xd4d7a0c (semid 15) created
# Udev cookie 0xd4d7a0c (semid 15) incremented to 1
# Udev cookie 0xd4d7a0c (semid 15) incremented to 2
# Udev cookie 0xd4d7a0c (semid 15) assigned to CREATE task(0) with flags DISABLE_LIBRARY_FALLBACK (0x20)
# dm create int-loop0 CRYPT-INTEGRITY-int-loop0 [ opencount flush ] [16384] (*1)
# dm reload int-loop0 [ opencount flush securedata ] [16384] (*1)
# dm resume int-loop0 [ opencount flush securedata ] [16384] (*1)
# int-loop0: Stacking NODE_ADD (254,38) 0:6 0660 [trust_udev]
# int-loop0: Stacking NODE_READ_AHEAD 256 (flags=1)
# Udev cookie 0xd4d7a0c (semid 15) decremented to 1
# Udev cookie 0xd4d7a0c (semid 15) waiting for zero
# Udev cookie 0xd4d7a0c (semid 15) destroyed
# int-loop0: Skipping NODE_ADD (254,38) 0:6 0660 [trust_udev]
# int-loop0: Processing NODE_READ_AHEAD 256 (flags=1)
# int-loop0 (254:38): read ahead is 256
# int-loop0: retaining kernel read ahead of 256 (requested 256)
# Releasing crypt device /dev/loop0 context.
# Releasing device-mapper backend.
# Closing read only fd for /dev/loop0.
Command successful.
+ integritysetup dump --debug /dev/loop0
# cryptsetup 2.3.4 processing "integritysetup dump --debug /dev/loop0"
# Running command dump.
# Allocating context for crypt device /dev/loop0.
# Trying to open and read device /dev/loop0 with direct-io.
# Initialising device-mapper backend library.
# Trying to load INTEGRITY crypt type from device /dev/loop0.
# Crypto backend (OpenSSL 1.1.1d 10 Sep 2019) initialized in cryptsetup library version 2.3.4.
# Detected kernel Linux 5.10.0-3-amd64 x86_64.
# Reusing open ro fd on device /dev/loop0
Info for integrity device /dev/loop0.
superblock_version 4
log2_interleave_sectors 15
integrity_tag_size 4
journal_sections 1
provided_data_sectors 20040
sector_size 512
log2_blocks_per_bitmap 15
flags dirty_bitmap fix_padding
# Releasing crypt device /dev/loop0 context.
# Releasing device-mapper backend.
# Closing read only fd for /dev/loop0.
Command successful.
+ integritysetup status --debug /dev/mapper/int-loop0
# cryptsetup 2.3.4 processing "integritysetup status --debug /dev/mapper/int-loop0"
# Running command status.
# Initialising device-mapper backend library.
# dm version [ opencount flush ] [16384] (*1)
# dm versions [ opencount flush ] [16384] (*1)
# Detected dm-ioctl version 4.43.0.
# Detected dm-crypt version 1.22.0.
# Detected dm-integrity version 1.6.0.
# Device-mapper backend running with UDEV support enabled.
# dm status int-loop0 [ opencount noflush ] [16384] (*1)
# Releasing device-mapper backend.
/dev/mapper/int-loop0 is active.
# Allocating crypt device context by device /dev/mapper/int-loop0.
# Initialising device-mapper backend library.
# dm versions [ opencount flush ] [16384] (*1)
# dm status int-loop0 [ opencount noflush ] [16384] (*1)
# Releasing device-mapper backend.
# Trying to open and read device /dev/loop0 with direct-io.
# Allocating context for crypt device /dev/loop0.
# Trying to open and read device /dev/loop0 with direct-io.
# Initialising device-mapper backend library.
# dm versions [ opencount flush ] [16384] (*1)
# dm table int-loop0 [ opencount flush securedata ] [16384] (*1)
# Trying to open and read device /dev/loop0 with direct-io.
type: INTEGRITY
# dm versions [ opencount flush ] [16384] (*1)
# dm table int-loop0 [ opencount flush securedata ] [16384] (*1)
# Trying to open and read device /dev/loop0 with direct-io.
tag size: 4
integrity: crc32c
device: /dev/loop0
loop: /home/alexander/img
sector size: 512 bytes
interleave sectors: 32768
size: 20040 sectors
mode: read/write
# dm versions [ opencount flush ] [16384] (*1)
# dm table int-loop0 [ opencount flush securedata ] [16384] (*1)
# dm status int-loop0 [ opencount noflush ] [16384] (*1)
# Integrity volume /dev/mapper/int-loop0 failure status is 0 20040 -.
failures: 0
bitmap 512-byte sectors per bit: 32768
bitmap flush interval: 10000 ms
journal: not active
# Releasing crypt device /dev/loop0 context.
# Releasing device-mapper backend.
Command successful.
+ dmsetup status --target integrity /dev/mapper/int-loop0
0 20040 integrity 0 20040 -
+ integritysetup close --debug /dev/mapper/int-loop0
# cryptsetup 2.3.4 processing "integritysetup close --debug /dev/mapper/int-loop0"
# Running command close.
# Allocating crypt device context by device /dev/mapper/int-loop0.
# Initialising device-mapper backend library.
# dm version [ opencount flush ] [16384] (*1)
# dm versions [ opencount flush ] [16384] (*1)
# Detected dm-ioctl version 4.43.0.
# Detected dm-crypt version 1.22.0.
# Detected dm-integrity version 1.6.0.
# Device-mapper backend running with UDEV support enabled.
# dm status int-loop0 [ opencount noflush ] [16384] (*1)
# Releasing device-mapper backend.
# Trying to open and read device /dev/loop0 with direct-io.
# Allocating context for crypt device /dev/loop0.
# Trying to open and read device /dev/loop0 with direct-io.
# Initialising device-mapper backend library.
# dm versions [ opencount flush ] [16384] (*1)
# dm table int-loop0 [ opencount flush securedata ] [16384] (*1)
# Trying to open and read device /dev/loop0 with direct-io.
# Deactivating volume /dev/mapper/int-loop0.
# dm versions [ opencount flush ] [16384] (*1)
# dm status int-loop0 [ opencount noflush ] [16384] (*1)
# dm versions [ opencount flush ] [16384] (*1)
# dm table int-loop0 [ opencount flush securedata ] [16384] (*1)
# Trying to open and read device /dev/loop0 with direct-io.
# dm versions [ opencount flush ] [16384] (*1)
# Udev cookie 0xd4db081 (semid 16) created
# Udev cookie 0xd4db081 (semid 16) incremented to 1
# Udev cookie 0xd4db081 (semid 16) incremented to 2
# Udev cookie 0xd4db081 (semid 16) assigned to REMOVE task(2) with flags DISABLE_LIBRARY_FALLBACK (0x20)
# dm remove int-loop0 [ opencount flush retryremove ] [16384] (*1)
# Udev cookie 0xd4db081 (semid 16) decremented to 0
# Udev cookie 0xd4db081 (semid 16) waiting for zero
# Udev cookie 0xd4db081 (semid 16) destroyed
# Releasing crypt device /dev/loop0 context.
# Releasing device-mapper backend.
Command successful.
+ integritysetup open -B --debug --integrity xxhash64 --integrity-recalculate /dev/loop0 int-loop0
# cryptsetup 2.3.4 processing "integritysetup open -B --debug --integrity xxhash64 --integrity-recalculate /dev/loop0 int-loop0"
# Running command open.
# Allocating context for crypt device /dev/loop0.
# Trying to open and read device /dev/loop0 with direct-io.
# Initialising device-mapper backend library.
# Trying to load INTEGRITY crypt type from device /dev/loop0.
# Crypto backend (OpenSSL 1.1.1d 10 Sep 2019) initialized in cryptsetup library version 2.3.4.
# Detected kernel Linux 5.10.0-3-amd64 x86_64.
# Activating volume int-loop0 by volume key.
# dm version [ opencount flush ] [16384] (*1)
# dm versions [ opencount flush ] [16384] (*1)
# Detected dm-ioctl version 4.43.0.
# Detected dm-crypt version 1.22.0.
# Detected dm-integrity version 1.6.0.
# Device-mapper backend running with UDEV support enabled.
# dm status int-loop0 [ opencount noflush ] [16384] (*1)
# Reusing open ro fd on device /dev/loop0
# Trying to activate INTEGRITY device on top of /dev/loop0, using name int-loop0, tag size 4, provided sectors 20040.
# DM-UUID is CRYPT-INTEGRITY-int-loop0
# Udev cookie 0xd4d6e64 (semid 17) created
# Udev cookie 0xd4d6e64 (semid 17) incremented to 1
# Udev cookie 0xd4d6e64 (semid 17) incremented to 2
# Udev cookie 0xd4d6e64 (semid 17) assigned to CREATE task(0) with flags DISABLE_LIBRARY_FALLBACK (0x20)
# dm create int-loop0 CRYPT-INTEGRITY-int-loop0 [ opencount flush ] [16384] (*1)
# dm reload int-loop0 [ opencount flush securedata ] [16384] (*1)
# dm resume int-loop0 [ opencount flush securedata ] [16384] (*1)
# int-loop0: Stacking NODE_ADD (254,38) 0:6 0660 [trust_udev]
# int-loop0: Stacking NODE_READ_AHEAD 256 (flags=1)
# Udev cookie 0xd4d6e64 (semid 17) decremented to 1
# Udev cookie 0xd4d6e64 (semid 17) waiting for zero
# Udev cookie 0xd4d6e64 (semid 17) destroyed
# int-loop0: Skipping NODE_ADD (254,38) 0:6 0660 [trust_udev]
# int-loop0: Processing NODE_READ_AHEAD 256 (flags=1)
# int-loop0 (254:38): read ahead is 256
# int-loop0: retaining kernel read ahead of 256 (requested 256)
# Releasing crypt device /dev/loop0 context.
# Releasing device-mapper backend.
# Closing read only fd for /dev/loop0.
Command successful.
+ sleep 60s
+ integritysetup dump --debug /dev/loop0
# cryptsetup 2.3.4 processing "integritysetup dump --debug /dev/loop0"
# Running command dump.
# Allocating context for crypt device /dev/loop0.
# Trying to open and read device /dev/loop0 with direct-io.
# Initialising device-mapper backend library.
# Trying to load INTEGRITY crypt type from device /dev/loop0.
# Crypto backend (OpenSSL 1.1.1d 10 Sep 2019) initialized in cryptsetup library version 2.3.4.
# Detected kernel Linux 5.10.0-3-amd64 x86_64.
# Reusing open ro fd on device /dev/loop0
Info for integrity device /dev/loop0.
superblock_version 4
log2_interleave_sectors 15
integrity_tag_size 4
journal_sections 1
provided_data_sectors 20040
sector_size 512
log2_blocks_per_bitmap 15
flags recalculating dirty_bitmap fix_padding
# Releasing crypt device /dev/loop0 context.
# Releasing device-mapper backend.
# Closing read only fd for /dev/loop0.
Command successful.
+ integritysetup status --debug /dev/mapper/int-loop0
# cryptsetup 2.3.4 processing "integritysetup status --debug /dev/mapper/int-loop0"
# Running command status.
# Initialising device-mapper backend library.
# dm version [ opencount flush ] [16384] (*1)
# dm versions [ opencount flush ] [16384] (*1)
# Detected dm-ioctl version 4.43.0.
# Detected dm-crypt version 1.22.0.
# Detected dm-integrity version 1.6.0.
# Device-mapper backend running with UDEV support enabled.
# dm status int-loop0 [ opencount noflush ] [16384] (*1)
# Releasing device-mapper backend.
/dev/mapper/int-loop0 is active.
# Allocating crypt device context by device /dev/mapper/int-loop0.
# Initialising device-mapper backend library.
# dm versions [ opencount flush ] [16384] (*1)
# dm status int-loop0 [ opencount noflush ] [16384] (*1)
# Releasing device-mapper backend.
# Trying to open and read device /dev/loop0 with direct-io.
# Allocating context for crypt device /dev/loop0.
# Trying to open and read device /dev/loop0 with direct-io.
# Initialising device-mapper backend library.
# dm versions [ opencount flush ] [16384] (*1)
# dm table int-loop0 [ opencount flush securedata ] [16384] (*1)
# Trying to open and read device /dev/loop0 with direct-io.
type: INTEGRITY
# dm versions [ opencount flush ] [16384] (*1)
# dm table int-loop0 [ opencount flush securedata ] [16384] (*1)
# Trying to open and read device /dev/loop0 with direct-io.
tag size: 4
integrity: xxhash64
device: /dev/loop0
loop: /home/alexander/img
sector size: 512 bytes
interleave sectors: 32768
size: 20040 sectors
mode: read/write
# dm versions [ opencount flush ] [16384] (*1)
# dm table int-loop0 [ opencount flush securedata ] [16384] (*1)
# dm status int-loop0 [ opencount noflush ] [16384] (*1)
# Integrity volume /dev/mapper/int-loop0 failure status is 0 20040 20040.
failures: 0
bitmap 512-byte sectors per bit: 32768
bitmap flush interval: 10000 ms
journal: not active
# Releasing crypt device /dev/loop0 context.
# Releasing device-mapper backend.
Command successful.
+ dmsetup status --target integrity /dev/mapper/int-loop0
0 20040 integrity 0 20040 20040
+ integritysetup close --debug /dev/mapper/int-loop0
# cryptsetup 2.3.4 processing "integritysetup close --debug /dev/mapper/int-loop0"
# Running command close.
# Allocating crypt device context by device /dev/mapper/int-loop0.
# Initialising device-mapper backend library.
# dm version [ opencount flush ] [16384] (*1)
# dm versions [ opencount flush ] [16384] (*1)
# Detected dm-ioctl version 4.43.0.
# Detected dm-crypt version 1.22.0.
# Detected dm-integrity version 1.6.0.
# Device-mapper backend running with UDEV support enabled.
# dm status int-loop0 [ opencount noflush ] [16384] (*1)
# Releasing device-mapper backend.
# Trying to open and read device /dev/loop0 with direct-io.
# Allocating context for crypt device /dev/loop0.
# Trying to open and read device /dev/loop0 with direct-io.
# Initialising device-mapper backend library.
# dm versions [ opencount flush ] [16384] (*1)
# dm table int-loop0 [ opencount flush securedata ] [16384] (*1)
# Trying to open and read device /dev/loop0 with direct-io.
# Deactivating volume /dev/mapper/int-loop0.
# dm versions [ opencount flush ] [16384] (*1)
# dm status int-loop0 [ opencount noflush ] [16384] (*1)
# dm versions [ opencount flush ] [16384] (*1)
# dm table int-loop0 [ opencount flush securedata ] [16384] (*1)
# Trying to open and read device /dev/loop0 with direct-io.
# dm versions [ opencount flush ] [16384] (*1)
# Udev cookie 0xd4d0737 (semid 18) created
# Udev cookie 0xd4d0737 (semid 18) incremented to 1
# Udev cookie 0xd4d0737 (semid 18) incremented to 2
# Udev cookie 0xd4d0737 (semid 18) assigned to REMOVE task(2) with flags DISABLE_LIBRARY_FALLBACK (0x20)
# dm remove int-loop0 [ opencount flush retryremove ] [16384] (*1)
# Udev cookie 0xd4d0737 (semid 18) decremented to 0
# Udev cookie 0xd4d0737 (semid 18) waiting for zero
# Udev cookie 0xd4d0737 (semid 18) destroyed
# Releasing crypt device /dev/loop0 context.
# Releasing device-mapper backend.
Command successful.
+ integritysetup open --debug -B --integrity crc32c --integrity-recalculate /dev/loop0 int-loop0
# cryptsetup 2.3.4 processing "integritysetup open --debug -B --integrity crc32c --integrity-recalculate /dev/loop0 int-loop0"
# Running command open.
# Allocating context for crypt device /dev/loop0.
# Trying to open and read device /dev/loop0 with direct-io.
# Initialising device-mapper backend library.
# Trying to load INTEGRITY crypt type from device /dev/loop0.
# Crypto backend (OpenSSL 1.1.1d 10 Sep 2019) initialized in cryptsetup library version 2.3.4.
# Detected kernel Linux 5.10.0-3-amd64 x86_64.
# Activating volume int-loop0 by volume key.
# dm version [ opencount flush ] [16384] (*1)
# dm versions [ opencount flush ] [16384] (*1)
# Detected dm-ioctl version 4.43.0.
# Detected dm-crypt version 1.22.0.
# Detected dm-integrity version 1.6.0.
# Device-mapper backend running with UDEV support enabled.
# dm status int-loop0 [ opencount noflush ] [16384] (*1)
# Reusing open ro fd on device /dev/loop0
# Trying to activate INTEGRITY device on top of /dev/loop0, using name int-loop0, tag size 4, provided sectors 20040.
# DM-UUID is CRYPT-INTEGRITY-int-loop0
# Udev cookie 0xd4d6a72 (semid 19) created
# Udev cookie 0xd4d6a72 (semid 19) incremented to 1
# Udev cookie 0xd4d6a72 (semid 19) incremented to 2
# Udev cookie 0xd4d6a72 (semid 19) assigned to CREATE task(0) with flags DISABLE_LIBRARY_FALLBACK (0x20)
# dm create int-loop0 CRYPT-INTEGRITY-int-loop0 [ opencount flush ] [16384] (*1)
# dm reload int-loop0 [ opencount flush securedata ] [16384] (*1)
# dm resume int-loop0 [ opencount flush securedata ] [16384] (*1)
# int-loop0: Stacking NODE_ADD (254,38) 0:6 0660 [trust_udev]
# int-loop0: Stacking NODE_READ_AHEAD 256 (flags=1)
# Udev cookie 0xd4d6a72 (semid 19) decremented to 1
# Udev cookie 0xd4d6a72 (semid 19) waiting for zero
# Udev cookie 0xd4d6a72 (semid 19) destroyed
# int-loop0: Skipping NODE_ADD (254,38) 0:6 0660 [trust_udev]
# int-loop0: Processing NODE_READ_AHEAD 256 (flags=1)
# int-loop0 (254:38): read ahead is 256
# int-loop0: retaining kernel read ahead of 256 (requested 256)
# Releasing crypt device /dev/loop0 context.
# Releasing device-mapper backend.
# Closing read only fd for /dev/loop0.
Command successful.
+ dmesg
+ tail
+ grep dm-
[78698.500163] device-mapper: integrity: dm-38: Checksum failed at sector 0x4d80
[78698.500409] device-mapper: integrity: dm-38: Checksum failed at sector 0x4d80
[78698.500491] Buffer I/O error on dev dm-38, logical block 2480, async page read
+ integritysetup dump --debug /dev/loop0
# cryptsetup 2.3.4 processing "integritysetup dump --debug /dev/loop0"
# Running command dump.
# Allocating context for crypt device /dev/loop0.
# Trying to open and read device /dev/loop0 with direct-io.
# Initialising device-mapper backend library.
# Trying to load INTEGRITY crypt type from device /dev/loop0.
# Crypto backend (OpenSSL 1.1.1d 10 Sep 2019) initialized in cryptsetup library version 2.3.4.
# Detected kernel Linux 5.10.0-3-amd64 x86_64.
# Reusing open ro fd on device /dev/loop0
Info for integrity device /dev/loop0.
superblock_version 4
log2_interleave_sectors 15
integrity_tag_size 4
journal_sections 1
provided_data_sectors 20040
sector_size 512
log2_blocks_per_bitmap 15
flags recalculating dirty_bitmap fix_padding
# Releasing crypt device /dev/loop0 context.
# Releasing device-mapper backend.
# Closing read only fd for /dev/loop0.
Command successful.
+ integritysetup status --debug /dev/mapper/int-loop0
# cryptsetup 2.3.4 processing "integritysetup status --debug /dev/mapper/int-loop0"
# Running command status.
# Initialising device-mapper backend library.
# dm version [ opencount flush ] [16384] (*1)
# dm versions [ opencount flush ] [16384] (*1)
# Detected dm-ioctl version 4.43.0.
# Detected dm-crypt version 1.22.0.
# Detected dm-integrity version 1.6.0.
# Device-mapper backend running with UDEV support enabled.
# dm status int-loop0 [ opencount noflush ] [16384] (*1)
# Releasing device-mapper backend.
/dev/mapper/int-loop0 is active.
# Allocating crypt device context by device /dev/mapper/int-loop0.
# Initialising device-mapper backend library.
# dm versions [ opencount flush ] [16384] (*1)
# dm status int-loop0 [ opencount noflush ] [16384] (*1)
# Releasing device-mapper backend.
# Trying to open and read device /dev/loop0 with direct-io.
# Allocating context for crypt device /dev/loop0.
# Trying to open and read device /dev/loop0 with direct-io.
# Initialising device-mapper backend library.
# dm versions [ opencount flush ] [16384] (*1)
# dm table int-loop0 [ opencount flush securedata ] [16384] (*1)
# Trying to open and read device /dev/loop0 with direct-io.
type: INTEGRITY
# dm versions [ opencount flush ] [16384] (*1)
# dm table int-loop0 [ opencount flush securedata ] [16384] (*1)
# Trying to open and read device /dev/loop0 with direct-io.
tag size: 4
integrity: crc32c
device: /dev/loop0
loop: /home/alexander/img
sector size: 512 bytes
interleave sectors: 32768
size: 20040 sectors
mode: read/write
# dm versions [ opencount flush ] [16384] (*1)
# dm table int-loop0 [ opencount flush securedata ] [16384] (*1)
# dm status int-loop0 [ opencount noflush ] [16384] (*1)
# Integrity volume /dev/mapper/int-loop0 failure status is 2 20040 20040.
failures: 2
bitmap 512-byte sectors per bit: 32768
bitmap flush interval: 10000 ms
journal: not active
# Releasing crypt device /dev/loop0 context.
# Releasing device-mapper backend.
Command successful.
+ dmsetup status --target integrity /dev/mapper/int-loop0
0 20040 integrity 2 20040 20040
+ integritysetup close --debug /dev/mapper/int-loop0
# cryptsetup 2.3.4 processing "integritysetup close --debug /dev/mapper/int-loop0"
# Running command close.
# Allocating crypt device context by device /dev/mapper/int-loop0.
# Initialising device-mapper backend library.
# dm version [ opencount flush ] [16384] (*1)
# dm versions [ opencount flush ] [16384] (*1)
# Detected dm-ioctl version 4.43.0.
# Detected dm-crypt version 1.22.0.
# Detected dm-integrity version 1.6.0.
# Device-mapper backend running with UDEV support enabled.
# dm status int-loop0 [ opencount noflush ] [16384] (*1)
# Releasing device-mapper backend.
# Trying to open and read device /dev/loop0 with direct-io.
# Allocating context for crypt device /dev/loop0.
# Trying to open and read device /dev/loop0 with direct-io.
# Initialising device-mapper backend library.
# dm versions [ opencount flush ] [16384] (*1)
# dm table int-loop0 [ opencount flush securedata ] [16384] (*1)
# Trying to open and read device /dev/loop0 with direct-io.
# Deactivating volume /dev/mapper/int-loop0.
# dm versions [ opencount flush ] [16384] (*1)
# dm status int-loop0 [ opencount noflush ] [16384] (*1)
# dm versions [ opencount flush ] [16384] (*1)
# dm table int-loop0 [ opencount flush securedata ] [16384] (*1)
# Trying to open and read device /dev/loop0 with direct-io.
# dm versions [ opencount flush ] [16384] (*1)
# Udev cookie 0xd4d0be9 (semid 20) created
# Udev cookie 0xd4d0be9 (semid 20) incremented to 1
# Udev cookie 0xd4d0be9 (semid 20) incremented to 2
# Udev cookie 0xd4d0be9 (semid 20) assigned to REMOVE task(2) with flags DISABLE_LIBRARY_FALLBACK (0x20)
# dm remove int-loop0 [ opencount flush retryremove ] [16384] (*1)
# Udev cookie 0xd4d0be9 (semid 20) decremented to 0
# Udev cookie 0xd4d0be9 (semid 20) waiting for zero
# Udev cookie 0xd4d0be9 (semid 20) destroyed
# Releasing crypt device /dev/loop0 context.
# Releasing device-mapper backend.
Command successful.
+ losetup -d /dev/loop0
+ rm img