lists.openwall.net   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  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aXLrxVR0tmPuzIyM@gondor.apana.org.au>
Date: Fri, 23 Jan 2026 11:32:21 +0800
From: Herbert Xu <herbert@...dor.apana.org.au>
To: Lianjie Wang <karin0.zst@...il.com>
Cc: Olivia Mackall <olivia@...enic.com>,
	David Laight <david.laight.linux@...il.com>,
	Jonathan McDowell <noodles@...a.com>, linux-crypto@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] hwrng: core - fix racing condition when stopping
 hwrng_fill

On Fri, Jan 23, 2026 at 10:52:17AM +0800, Herbert Xu wrote:
> On Sun, Dec 21, 2025 at 09:24:48PM +0900, Lianjie Wang wrote:
> > 
> > Besides, if the hwrng_unregister() call happens immediately after a
> > hwrng_register() before, the stopped thread may have never been running,
> 
> How can this happen? Surely that would mean that the kthread_* API is
> broken?

OK, kthread_stop can stop the thread without ever calling threadfn.

However, rather than having unregisters/registers firing off in
parallel, let's just make sure that register cannot start until
the unregister is actually done.

The thing that's stopping us from waiting on kthread while holding
the mutex is the get_current_rng() call in the kthread.

We could get around this by converting the lock for get_current_rng
to RCU instead.  That should allow hwrng_unregister to safely wait
on the kthread without dead-lock.

Cheers,
-- 
Email: Herbert Xu <herbert@...dor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ