mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-12 19:30:04 +01:00
Add global serialization lock for memory hard PBKDF.
This is very ugly workaround for situation when multiple devices are being activated in parallel (systemd crypttab) and system instead of returning ENOMEM use OOM killer to randomly kill processes. This flag is intended to be used only in very specific situations.
This commit is contained in:
@@ -339,6 +339,12 @@ static int luks2_keyslot_get_key(struct crypt_device *cd,
|
||||
return -EINVAL;
|
||||
keyslot_key_len = json_object_get_int(jobj2);
|
||||
|
||||
/*
|
||||
* If requested, serialize unlocking for memory-hard KDF. Usually NOOP.
|
||||
*/
|
||||
if (pbkdf.max_memory_kb && crypt_serialize_lock(cd))
|
||||
return -EINVAL;
|
||||
|
||||
/*
|
||||
* Allocate derived key storage space.
|
||||
*/
|
||||
@@ -361,6 +367,9 @@ static int luks2_keyslot_get_key(struct crypt_device *cd,
|
||||
pbkdf.iterations, pbkdf.max_memory_kb,
|
||||
pbkdf.parallel_threads);
|
||||
|
||||
if (pbkdf.max_memory_kb)
|
||||
crypt_serialize_unlock(cd);
|
||||
|
||||
if (r == 0) {
|
||||
log_dbg(cd, "Reading keyslot area [0x%04x].", (unsigned)area_offset);
|
||||
/* FIXME: sector_offset should be size_t, fix LUKS_decrypt... accordingly */
|
||||
|
||||
Reference in New Issue
Block a user