cryptenroll,cryptsetup,shutdown: only call mlockall if we have CAP_IPC_LOCK
Calling mlockall in an unprivileged process most notably had the effect of making systemd-cryptenroll OOM while trying to open a normal-sized argon2 keyslot due to it hitting RLIMIT_MEMLOCK.
This commit is contained in:
@@ -401,9 +401,9 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
init_watchdog();
|
||||
|
||||
/* Lock us into memory */
|
||||
(void) mlockall(MCL_FUTURE|MCL_ONFAULT);
|
||||
(void) mlockall(MCL_CURRENT);
|
||||
/* Lock us into memory. If the first mlockall call fails, don't attempt it again. */
|
||||
if (safe_mlockall(MCL_FUTURE|MCL_ONFAULT) >= 0)
|
||||
(void) mlockall(MCL_CURRENT);
|
||||
|
||||
/* We need to make mounts private so that we can MS_MOVE in unmount_all(). Kernel does not allow
|
||||
* MS_MOVE when parent mountpoints have shared propagation. */
|
||||
|
||||
Reference in New Issue
Block a user