Skip to content

Commit

Permalink
Abort online reencryption for misconfigured devices.
Browse files Browse the repository at this point in the history
Hard abort is justified here. The online reencryption on
data devices that do not support O_DIRECT io flag is
dangerous and leads to data corruption. This should be
impossible to hit due to a patch that handles it
in initialization phase. Better safe than sorry.
  • Loading branch information
oniko authored and mbroz committed Sep 2, 2024
1 parent 51920e0 commit f05d78d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/luks2/luks2_reencrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -4230,9 +4230,14 @@ int crypt_reencrypt_run(

log_dbg(cd, "Resuming LUKS2 reencryption.");

if (rh->online && reencrypt_init_device_stack(cd, rh)) {
log_err(cd, _("Failed to initialize reencryption device stack."));
return -EINVAL;
if (rh->online) {
/* This is last resort to avoid data corruption. Abort is justified here. */
assert(device_direct_io(crypt_data_device(cd)));

if (reencrypt_init_device_stack(cd, rh)) {
log_err(cd, _("Failed to initialize reencryption device stack."));
return -EINVAL;
}
}

log_dbg(cd, "Progress %" PRIu64 ", device_size %" PRIu64, rh->progress, rh->device_size);
Expand Down

0 comments on commit f05d78d

Please sign in to comment.