Skip to content

Commit 77251e4

Browse files
ebiggersherbertx
authored andcommitted
crypto: algboss - don't wait during notifier callback
When a crypto template needs to be instantiated, CRYPTO_MSG_ALG_REQUEST is sent to crypto_chain. cryptomgr_schedule_probe() handles this by starting a thread to instantiate the template, then waiting for this thread to complete via crypto_larval::completion. This can deadlock because instantiating the template may require loading modules, and this (apparently depending on userspace) may need to wait for the crc-t10dif module (lib/crc-t10dif.c) to be loaded. But crc-t10dif's module_init function uses crypto_register_notifier() and therefore takes crypto_chain.rwsem for write. That can't proceed until the notifier callback has finished, as it holds this semaphore for read. Fix this by removing the wait on crypto_larval::completion from within cryptomgr_schedule_probe(). It's actually unnecessary because crypto_alg_mod_lookup() calls crypto_larval_wait() itself after sending CRYPTO_MSG_ALG_REQUEST. This only actually became a problem in v4.20 due to commit b763775 ("crc-t10dif: Pick better transform if one becomes available"), but the unnecessary wait was much older. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=207159 Reported-by: Mike Gerow <[email protected]> Fixes: 3987103 ("crypto: algapi - Move larval completion into algboss") Cc: <[email protected]> # v3.6+ Cc: Martin K. Petersen <[email protected]> Signed-off-by: Eric Biggers <[email protected]> Reported-by: Kai Lüke <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 24c7bf0 commit 77251e4

File tree

1 file changed

+0
-2
lines changed

1 file changed

+0
-2
lines changed

crypto/algboss.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,6 @@ static int cryptomgr_schedule_probe(struct crypto_larval *larval)
178178
if (IS_ERR(thread))
179179
goto err_put_larval;
180180

181-
wait_for_completion_interruptible(&larval->completion);
182-
183181
return NOTIFY_STOP;
184182

185183
err_put_larval:

0 commit comments

Comments
 (0)