Commit 634445a6 authored by Eric Biggers's avatar Eric Biggers Committed by Ard Biesheuvel
Browse files

ANDROID: fips140: fix deadlock in unregister_existing_fips140_algos()



crypto_remove_final() calls crypto_alg_put() which can take
crypto_alg_sem again, via a call stack like:

    down_write(&crypto_alg_sem)
    crypto_drop_spawn()
    crypto_ccm_free()
    crypto_aead_free_instance()
    crypto_destroy_instance()
    crypto_alg_put() (inlined)
    crypto_remove_final()
    unregister_existing_fips140_algos()

That causes a deadlock because unregister_existing_fips140_algos() is
already holding crypto_alg_sem.

Fix this by reducing the scope of crypto_alg_sem to the actual list
traversal and not the crypto_alg_put().

Bug: 153614920
Bug: 188620248
Change-Id: Ia724d8b13480233dad051c538dc504cb27be8777
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
parent 0af06624
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment