mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-05 16:00:05 +01:00
Use free physical memory check for pbkdf only on small systems.
This hack tries to workaround situation when small VMs without swap causes OOM. This hack will be removed one day completely... Also remove confusing warning about possible crash. With OpenSSL Argon2 backend this behaves much better, but it still can cause OOM instead od returning ENOMEM. Anyway, the warning message causes more problems that it solves. Fixes: #896
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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();
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user