mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [PATCH] Add getrandom syscall wrapper function
Date: Tue, 2 Jan 2018 13:09:37 -0500	[thread overview]
Message-ID: <20180102180937.GL1627@brightrain.aerifal.cx> (raw)
In-Reply-To: <20180102152758.GB4871@port70.net>

On Tue, Jan 02, 2018 at 04:27:59PM +0100, Szabolcs Nagy wrote:
> * Rich Felker <dalias@libc.org> [2018-01-01 21:14:03 -0500]:
> > > > glibc does not have a fallback for this syscall there was a long
> > > > discussion about this, see here: https://lwn.net/Articles/711013/
> > > > As they never found a good solution for their fallback. I think musl
> > > > should also not provide a fallback.
> > 
> > Interesting that the biggest issue seems to have been about using file
> > descriptors as the fallback. That's something I never considered using
> > in musl since we have AT_RANDOM and sysctl on ancient kernels that
> > lack it. There are a small number of kernels between when sysctl
> > started spamming syslog with deprecation warnings and when AT_RANDOM
> > was added but I don't really care about those; it still works anyway.
> 
> note that getrandom gives new entropy after fork
> but AT_RANDOM is the same.

The concept of "new entropy" is not meaningful. Yes, a naive
AT_RANDOM-based approach would share state between parent and child in
a program that forks without exec, which would be bad, but the obvious
way you do this is (1) consume AT_RANDOM and overwrite it with the
output of the internal csPRNG so that getauxval(AT_RANDOM) doesn't
leak sensitive state, and (2) step the csPRNG twice at fork, using the
outputs as the new state in the parent and child so that neither can
predict the other's state.

Admittedly such a random number source is not hard against
heartbleed-type attacks, so you probably should still prefer
SYS_getrandom when it's available. On modern systems where people
really care, it will be available anyway.

Rich


      reply	other threads:[~2018-01-02 18:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-01 20:31 Hauke Mehrtens
2018-01-01 20:47 ` Rich Felker
2018-01-01 21:51   ` Hauke Mehrtens
2018-01-01 22:03     ` Rich Felker
2018-01-02  2:14       ` Rich Felker
2018-01-02 15:27         ` Szabolcs Nagy
2018-01-02 18:09           ` Rich Felker [this message]

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=20180102180937.GL1627@brightrain.aerifal.cx \
    --to=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).