Skip to content

Commit dc560eb

Browse files
committed
luks: Sanity check master key and slot iterations
These should never be zero. We should probably limit them too, but that can be done at a future time. Thanks: Daniel P. Berrangé Updates: commit 468919d
1 parent 73ccb80 commit dc560eb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

filters/luks/luks-encryption.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,12 @@ load_header (nbdkit_next *next, const char *passphrase)
744744
return NULL;
745745
}
746746

747+
if (h->phdr.master_key_digest_iterations == 0) {
748+
nbdkit_error ("bad LUKSv1 header: master key iterations is 0");
749+
free (h);
750+
return NULL;
751+
}
752+
747753
/* We derive several allocations from master_key_len so make sure
748754
* it's not insane.
749755
*/
@@ -769,6 +775,11 @@ load_header (nbdkit_next *next, const char *passphrase)
769775
free (h);
770776
return NULL;
771777
}
778+
if (ks->password_iterations == 0) {
779+
nbdkit_error ("bad LUKSv1 header: key slot %zu iterations is 0", i);
780+
free (h);
781+
return NULL;
782+
}
772783
start = ks->key_material_offset;
773784
len = key_material_length_in_sectors (h, i);
774785
if (len > 4096) /* bound it at something reasonable */ {

0 commit comments

Comments
 (0)