From e6f6ee9291c042c58dd66cb0bf00f302b9275fbf Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Wed, 14 May 2025 14:55:17 +0200 Subject: [PATCH] Do not allow PBKDF benchmark over maximum allowed threads. Unfortunatelly the benchmark function cannot return corrected parallel cost, so it must fail. Note that some backends (like OpenSSL) also limits maximal thread count, so currently it was clapped at 4 for luksFormat and 8 for benchmark. This patch set it all to PBKDF internal parallel limit. --- lib/crypto_backend/pbkdf_check.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/crypto_backend/pbkdf_check.c b/lib/crypto_backend/pbkdf_check.c index 30b1bebd..5eb21f33 100644 --- a/lib/crypto_backend/pbkdf_check.c +++ b/lib/crypto_backend/pbkdf_check.c @@ -408,6 +408,9 @@ int crypt_pbkdf_perf(const char *kdf, const char *hash, if (r < 0) return r; + if (parallel_threads > pbkdf_limits.max_parallel) + return -EINVAL; + min_memory = pbkdf_limits.min_bench_memory; if (min_memory > max_memory_kb) min_memory = max_memory_kb;