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:
cyclopentane
2026-01-18 19:15:30 +01:00
committed by Mike Yuan
parent 6b3c289406
commit 465f6a6284
5 changed files with 31 additions and 5 deletions
+2 -1
View File
@@ -27,6 +27,7 @@
#include "parse-util.h"
#include "pkcs11-util.h"
#include "pretty-print.h"
#include "process-util.h"
#include "string-table.h"
#include "string-util.h"
#include "tpm2-pcr.h"
@@ -850,7 +851,7 @@ static int run(int argc, char *argv[]) {
return r;
/* A delicious drop of snake oil */
(void) mlockall(MCL_CURRENT|MCL_FUTURE|MCL_ONFAULT);
(void) safe_mlockall(MCL_CURRENT|MCL_FUTURE|MCL_ONFAULT);
cryptsetup_enable_logging(NULL);