lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 20 May 2020 22:39:11 +0530
From:   Vinay Kumar Yadav <>
To:     David Miller <>
Subject: Re: [PATCH net-next] net/tls: fix race condition causing kernel panic


On 5/20/2020 12:46 AM, David Miller wrote:
> From: Vinay Kumar Yadav <>
> Date: Tue, 19 May 2020 13:13:27 +0530
>> +		spin_lock_bh(&ctx->encrypt_compl_lock);
>> +		pending = atomic_read(&ctx->encrypt_pending);
>> +		spin_unlock_bh(&ctx->encrypt_compl_lock);
> The sequence:
> 	lock();
> 	x = p->y;
> 	unlock();
> Does not fix anything, and is superfluous locking.
> The value of p->y can change right after the unlock() call, so you
> aren't protecting the atomic'ness of the read and test sequence
> because the test is outside of the lock.

Here, by using lock I want to achieve atomicity of following statements.

pending = atomic_dec_return(&ctx->decrypt_pending);
       if (!pending && READ_ONCE(ctx->async_notify))

means, don't want to read (atomic_read(&ctx->decrypt_pending))
in middle of two statements


Why am I protecting only read, not test ?

complete() is called only if pending == 0
if we read atomic_read(&ctx->decrypt_pending) = 0
that means complete() is already called and its okay to
initialize completion (reinit_completion(&ctx->async_wait.completion))

if we read atomic_read(&ctx->decrypt_pending) as non zero that means:
1- complete() is going to be called or
2- complete() already called (if we read atomic_read(&ctx->decrypt_pending) == 1, then complete() is called just after unlock())
for both scenario its okay to go into wait (crypto_wait_req(-EINPROGRESS, &ctx->async_wait))


Powered by blists - more mailing lists