[v2 PATCH 0/2] crypto: Fix race condition in *_check_key

From: Herbert Xu
Date: Fri Jan 15 2016 - 08:59:12 EST


On Fri, Jan 15, 2016 at 10:06:11AM +0100, Dmitry Vyukov wrote:
>
> With these patches I see lots of:
>
> [ INFO: possible recursive locking detected ]
> 4.4.0+ #250 Not tainted
> ---------------------------------------------
> syz-executor/16742 is trying to acquire lock:
> (sk_lock-AF_ALG){+.+.+.}, at: [< inline >] lock_sock
> include/net/sock.h:1480
> (sk_lock-AF_ALG){+.+.+.}, at: [<ffffffff828661d2>]
> hash_check_key.isra.3+0xd2/0x210 crypto/algif_hash.c:261
>
> but task is already holding lock:
> (sk_lock-AF_ALG){+.+.+.}, at: [< inline >] lock_sock
> include/net/sock.h:1480
> (sk_lock-AF_ALG){+.+.+.}, at: [<ffffffff82866126>]
> hash_check_key.isra.3+0x26/0x210 crypto/algif_hash.c:252
>
> other info that might help us debug this:
> Possible unsafe locking scenario:
>
> CPU0
> ----
> lock(sk_lock-AF_ALG);
> lock(sk_lock-AF_ALG);
>
> *** DEADLOCK ***
>
> May be due to missing lock nesting notation

Indeed. Here is an updated version.
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt