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

From: Dmitry Vyukov
Date: Fri Jan 15 2016 - 12:31:12 EST


On Fri, Jan 15, 2016 at 2:59 PM, Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> wrote:
> 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.

With these patches the original bug is fixed and don't see any new.

Tested-by: Dmitry Vyukov <dvyukov@xxxxxxxxxx>