From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12978 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: arc4random/csprng Date: Tue, 3 Jul 2018 10:47:14 -0400 Message-ID: <20180703144714.GM1392@brightrain.aerifal.cx> References: <20180702203957.GA9081@brightrain.aerifal.cx> <647a7190-b70b-23a2-9b3c-a24b44fcac99@redhat.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1530629125 16566 195.159.176.226 (3 Jul 2018 14:45:25 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 3 Jul 2018 14:45:25 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) Cc: musl@lists.openwall.com To: Florian Weimer Original-X-From: musl-return-12994-gllmg-musl=m.gmane.org@lists.openwall.com Tue Jul 03 16:45:21 2018 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1faMYS-0004E4-HY for gllmg-musl@m.gmane.org; Tue, 03 Jul 2018 16:45:20 +0200 Original-Received: (qmail 20315 invoked by uid 550); 3 Jul 2018 14:47:29 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 20294 invoked from network); 3 Jul 2018 14:47:28 -0000 Content-Disposition: inline In-Reply-To: <647a7190-b70b-23a2-9b3c-a24b44fcac99@redhat.com> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:12978 Archived-At: On Tue, Jul 03, 2018 at 03:36:59PM +0200, Florian Weimer wrote: > On 07/02/2018 10:39 PM, Rich Felker wrote: > >I haven't followed what's been happening with posix_random lately, but > >glibc has adding the arc4random interfaces and it seems reasonable > >that we should too, with the easy option to add the posix_random name > >for it and whatever interface details POSIX decides on. > > Note that it's probably not going to make it into glibc 2.28 at this point. Now the race is on, I guess. ;-) > >One topic I thought was a huge bikeshed was the whole fork-detection > >or fork-safety thing, but apparently it's not for glibc and perhaps > >other implementations because they've opted to make their csprng > >lock-free and incurred a lot of complexity with safely replacing > >pseudo-immutable state. I want to avoid most or all of this issue by > >just using a proper lock, but it might still be necessary to do some > >nasty hack for the case where fork is called from a signal handler > >interrupting the csprng. The only way to avoid that entirely is to > >block signals while the csprng runs, which is probably unjustifiably > >slow. > > The main lock (for non-current kernels) is needed for the fork > detection counters. Fork detection is required for compatibility > with applications which call clone/fork system calls directly, so How do you consider this supported usage at all? The tid in the TCB will be invalid after such a call, and other things may be broken too. IMO after syscall(SYS_fork or SYS_clone) the application is in an async-signal (or even more restricted) context and certainly can't use high level interfaces like arc4random. Rich