]> git.ipfire.org Git - thirdparty/qemu.git/commit
crypto: run qcrypto_pbkdf2_count_iters in a new thread
authorTiago Pasqualini <tiago.pasqualini@canonical.com>
Wed, 4 Sep 2024 23:52:30 +0000 (20:52 -0300)
committerMichael Tokarev <mjt@tls.msk.ru>
Thu, 12 Sep 2024 01:17:55 +0000 (04:17 +0300)
commit387d044a8000776af43bc085bb095f8fad194153
tree4105b7942c0d452707309b2a6dcae281c369bab1
parentbba2372cb821926ae0ff40602999438b38e25871
crypto: run qcrypto_pbkdf2_count_iters in a new thread

CPU time accounting in the kernel has been demonstrated to have a
sawtooth pattern[1][2]. This can cause the getrusage system call to
not be as accurate as we are expecting, which can cause this calculation
to stall.

The kernel discussions shows that this inaccuracy happens when CPU time
gets big enough, so this patch changes qcrypto_pbkdf2_count_iters to run
in a fresh thread to avoid this inaccuracy. It also adds a sanity check
to fail the process if CPU time is not accounted.

[1] https://lore.kernel.org/lkml/159231011694.16989.16351419333851309713.tip-bot2@tip-bot2/
[2] https://lore.kernel.org/lkml/20221226031010.4079885-1-maxing.lan@bytedance.com/t/#m1c7f2fdc0ea742776a70fd1aa2a2e414c437f534

Resolves: #2398
Signed-off-by: Tiago Pasqualini <tiago.pasqualini@canonical.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit c72cab5ad9f849bbcfcf4be7952b8b8946cc626e)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
crypto/pbkdf.c