Re: [PATCH] crypto: only wait for completion once
From: John Mathew <hidden>
Date: 2020-02-11 11:49:12
On Tue, Jan 14, 2020 at 2:47 PM Sebastian Andrzej Siewior [off-list ref] wrote:
On 2019-12-31 12:00:51 [+0200], John Mathew wrote:quoted
Proposed fix for the swake_up_all_locked warnings issue discussed in Link: https://lore.kernel.org/linux-rt-users/20191218165334.k4suur4gzlu62ibs@linutronix.de/T/#t (local) Currently multiple wait for completions are scheduled for the same algo. Only one completes and the rest are returned with ENOENT. This patch checks for the name of the algorithm going to be waited up on, and if the algorithm is already being waited for completion return EAGAIN , without accumulating completions and returning ENOENT.Have you tested this patch and if so how?
I ran the syzkaller for many days and was not able to reproduce the hang, also no new issues were found. Do you know any more tests for the crypto functionality?
quoted
Signed-off-by: John Mathew <redacted> --- crypto/api.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)diff --git a/crypto/api.c b/crypto/api.c index d8ba54142620..1c6004e7ab6c 100644 --- a/crypto/api.c +++ b/crypto/api.c@@ -234,8 +234,12 @@ static struct crypto_alg *crypto_larval_lookup(const char *name, u32 type, alg = crypto_alg_lookup(name, type, mask); } - if (!IS_ERR_OR_NULL(alg) && crypto_is_larval(alg)) - alg = crypto_larval_wait(alg); + if (!IS_ERR_OR_NULL(alg) && crypto_is_larval(alg)) { + if (!strcmp(alg->cra_name, name)) + alg = ERR_PTR(-EAGAIN); + else + alg = crypto_larval_wait(alg); + } else if (!alg) alg = crypto_larval_add(name, type, mask);Sebastian