[v2,0/2] crypto: Fix race condition in *_check_key
mbox series

Message ID 20160115135900.GA31813@gondor.apana.org.au
Headers show
Series
  • crypto: Fix race condition in *_check_key
Related show

Message

Herbert Xu Jan. 15, 2016, 1:59 p.m. UTC
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.

Comments

Dmitry Vyukov Jan. 15, 2016, 5:30 p.m. UTC | #1
On Fri, Jan 15, 2016 at 2:59 PM, Herbert Xu <herbert@gondor.apana.org.au> 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@google.com>