mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-05 16:00:05 +01:00
Lock memory in crypt_safe alloc functions.
This patch locks all memory ranges in safe allocations. While crypto backend can have some secure memory calls, it is usually limited by intitial config. For our use is enough to keep keys in memory and prevent swapping it out. If the lock fails (because of limits) we quietly stay with plain malloc.
This commit is contained in:
@@ -179,7 +179,7 @@ int crypt_keyfile_device_read(struct crypt_device *cd, const char *keyfile,
|
||||
key_size = DEFAULT_KEYFILE_SIZE_MAXKB * 1024 + 1;
|
||||
unlimited_read = 1;
|
||||
/* use 4k for buffer (page divisor but avoid huge pages) */
|
||||
buflen = 4096 - sizeof(size_t); // sizeof(struct safe_allocation);
|
||||
buflen = 4096 - 16; /* sizeof(struct safe_allocation); */
|
||||
} else
|
||||
buflen = key_size;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user