Skip to content

Commit

Permalink
Fix shared activation for dm-verity devices.
Browse files Browse the repository at this point in the history
CRYPT_ACTIVATE_SHARED flag was silently ignored
while activating dm-verity devices by libcryptsetup.
This was a bug.

DM verity shared activation is generaly safe (single mapped data device
in multiple DM verity tables) since all verity devices are
read only.

The CRYPT_ACTIVATE_SHARED flag also fixes a race condition
when multiple processes compete for the same DM device name
(all dm-verity) while using same backing data device.

The exclusive open check in-before verity activation could
fail DM table load for a process that otherwise successfully acquired
DM device name (succeed in creating the DM device). This could (in some
cases) result in all processes competening for the DM verity device
to fail and none would activate the DM verity device.
  • Loading branch information
oniko authored and mbroz committed Jul 24, 2024
1 parent 5873a65 commit ec9b97a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/verity/verity.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ int VERITY_activate(struct crypt_device *cd,
if (r)
goto out;

r = device_block_adjust(cd, crypt_data_device(cd), DEV_EXCL,
r = device_block_adjust(cd, crypt_data_device(cd),
activation_flags & CRYPT_ACTIVATE_SHARED ? DEV_OK : DEV_EXCL,
0, &dmd.size, &dmd.flags);
if (r)
goto out;
Expand Down

0 comments on commit ec9b97a

Please sign in to comment.