mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: musl@lists.openwall.com, Rich Felker <dalias@libc.org>
Subject: Re: arc4random/csprng
Date: Tue, 3 Jul 2018 15:36:59 +0200	[thread overview]
Message-ID: <647a7190-b70b-23a2-9b3c-a24b44fcac99@redhat.com> (raw)
In-Reply-To: <20180702203957.GA9081@brightrain.aerifal.cx>

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.

> 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 that the 
fork handler will not run.  Without MADV_WIPEONFORK, the only reliable 
thing I came up with is the dual-counter approach (MAP_PRIVATE vs 
MAP_SHARED) and something like software TM.  At that point, avoiding the 
lock for bit generation itself is just a very minor change.

Thanks,
Florian


  reply	other threads:[~2018-07-03 13:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-02 20:39 arc4random/csprng Rich Felker
2018-07-03 13:36 ` Florian Weimer [this message]
2018-07-03 14:47   ` arc4random/csprng Rich Felker
2018-07-03 15:08     ` arc4random/csprng Florian Weimer
2018-07-03 15:17       ` arc4random/csprng Rich Felker
2018-07-04 11:36         ` arc4random/csprng Florian Weimer
2018-07-04 15:13           ` arc4random/csprng Rich Felker
2018-07-03 14:18 ` arc4random/csprng Luca Barbato
2018-07-03 14:49   ` arc4random/csprng Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=647a7190-b70b-23a2-9b3c-a24b44fcac99@redhat.com \
    --to=fweimer@redhat.com \
    --cc=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).