diff --git a/lib/luks2/luks2_keyslot_luks2.c b/lib/luks2/luks2_keyslot_luks2.c index bb9ebee5..b823a3f8 100644 --- a/lib/luks2/luks2_keyslot_luks2.c +++ b/lib/luks2/luks2_keyslot_luks2.c @@ -305,7 +305,7 @@ static int luks2_keyslot_get_key(struct crypt_device *cd, const char *password, size_t passwordLen, char *volume_key, size_t volume_key_len) { - struct crypt_pbkdf_type pbkdf, *cd_pbkdf; + struct crypt_pbkdf_type pbkdf; char *AfKey = NULL; size_t AFEKSize; const char *af_hash = NULL; @@ -360,16 +360,6 @@ static int luks2_keyslot_get_key(struct crypt_device *cd, goto out; } - /* - * Print warning when keyslot requires more memory than available - * (if maximum memory was adjusted - no swap, not enough memory), - * but be silent if user set keyslot memory cost above default limit intentionally. - */ - cd_pbkdf = crypt_get_pbkdf(cd); - if (cd_pbkdf->max_memory_kb && pbkdf.max_memory_kb > cd_pbkdf->max_memory_kb && - pbkdf.max_memory_kb <= DEFAULT_LUKS2_MEMORY_KB) - log_std(cd, _("Warning: keyslot operation could fail as it requires more than available memory.\n")); - /* * If requested, serialize unlocking for memory-hard KDF. Usually NOOP. */ diff --git a/lib/utils_pbkdf.c b/lib/utils_pbkdf.c index b54509c8..487a6095 100644 --- a/lib/utils_pbkdf.c +++ b/lib/utils_pbkdf.c @@ -63,9 +63,11 @@ uint32_t pbkdf_adjusted_phys_memory_kb(void) memory_kb /= 2; /* - * Never use more that half of available free memory on system without swap. + * On systems with < 4GB RAM without swap + * never use more that half of available free memory. + * This is a temporary hack to avoid OOM on small systems. */ - if (!crypt_swapavailable()) { + if (memory_kb < (2 * 1024 * 1024) && !crypt_swapavailable()) { free_kb = crypt_getphysmemoryfree_kb(); /*