public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: "Adhemerval Zanella Netto" <adhemerval.zanella@linaro.org>,
	"Zack Weinberg" <zack@owlfolio.org>,
	"Cristian Rodríguez" <cristian@rodriguez.im>,
	"Florian Weimer" <fweimer@redhat.com>
Cc: Wilco Dijkstra <Wilco.Dijkstra@arm.com>,
	GNU libc development <libc-alpha@sourceware.org>,
	"Jason A. Donenfeld" <Jason@zx2c4.com>
Subject: Re: [PATCH 2/2] Add single-threaded fast path to rand()
Date: Fri, 22 Mar 2024 15:47:43 -0400	[thread overview]
Message-ID: <6a938fb2-30a5-4589-9b58-10828823df6f@efficios.com> (raw)
In-Reply-To: <50b42519-4557-4e8c-8a58-0077168aa25d@linaro.org>

On 2024-03-22 14:05, Adhemerval Zanella Netto wrote:
> 
> 
> On 22/03/24 12:30, Zack Weinberg wrote:
>> On Fri, Mar 22, 2024, at 10:46 AM, Adhemerval Zanella Netto wrote:
>>> On 22/03/24 11:27, Zack Weinberg wrote:
>>>> On Thu, Mar 21, 2024, at 11:53 AM, Adhemerval Zanella Netto wrote:
>>>>> And even if arc4random is explicit a non CPRNG, there were some worries that
>>>>> users might misuse the interface and thus add some security issues.
>>>>
>>>> No opinion about anything else in this thread, but if we add arc4random at all
>>>> it MUST be a CSPRNG.  That's a documented guarantee on all the systems that
>>>> do have it, and applications rely on it.
>>>
>>> Yeah, this is another point of contention where one might consider that a
>>> userland CPRNG that has no feedback from kernel to where/how to properly
>>> reseed might not be considered a CPRNG.
>>
>> I would describe that as a "CSPRNG with a known bug that makes it unsuitable
>> for use under some conditions", but not as "not a CSPRNG".  I would only
>> call it "not a CSPRNG" if the cryptographic primitives were no good
>> (e.g. RC4 or Xorshift or something even more predictable) or if there was
>> a way to leak or clone the state *in a single-threaded program that does
>> not fork*.
> 
> I tend to agree, but the contention point was really 'that makes it unsuitable
> for use under some conditions' was a deal breaker in face that kernel provides
> an API with better guarantees.
> 
>>
>> On a related note, why is MADV_WIPEONFORK not adequate "feedback from the
>> kernel"?
> 
> If I recall correctly, the problem was not only state wipe on fork (with
> MADV_WIPEONFORK should take care), but rather when the state needs to be
> reseed due various situations outside of the userland knowledge (on the
> arc4random thread Jason gave us some examples, I don't really recall all
> of them by hearth). That's why the idea of providing the arc4random through
> a vDSO primitive (where kernel can reseed any time it likes).

If the goal is to let userspace know that it needs to reseed due to
various kernel events happening, one way I see we could extend rseq
to support this would be to add a 64-bit "seed generation counter"
in the struct rseq per-thread area which would be incremented by the
kernel when the seed needs to be updated in userspace.

This would allow many userspace PRNG libraries to use this facility
within a process, as there would be no single per-library location the
kernel needs to reset, and would remove all knowledge of the PRNG
internal state from the kernel.

Thoughts ?

Thanks,

Mathieu

-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com


  reply	other threads:[~2024-03-22 19:47 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-18 15:20 Wilco Dijkstra
2024-03-18 19:24 ` Cristian Rodríguez
2024-03-19 15:44   ` Wilco Dijkstra
2024-03-20 12:31     ` Adhemerval Zanella Netto
2024-03-20 14:18       ` Cristian Rodríguez
2024-03-20 14:27         ` Adhemerval Zanella Netto
2024-03-21  7:39           ` Florian Weimer
2024-03-21 13:33             ` Cristian Rodríguez
2024-03-21 14:35               ` Mathieu Desnoyers
2024-03-21 15:07                 ` Szabolcs Nagy
2024-03-21 15:18                   ` Wilco Dijkstra
2024-03-21 15:53               ` Adhemerval Zanella Netto
2024-03-22 14:27                 ` Zack Weinberg
2024-03-22 14:46                   ` Adhemerval Zanella Netto
2024-03-22 15:30                     ` Zack Weinberg
2024-03-22 18:05                       ` Adhemerval Zanella Netto
2024-03-22 19:47                         ` Mathieu Desnoyers [this message]
2024-03-22 22:54                           ` Cristian Rodríguez
2024-03-23 14:01                           ` Zack Weinberg
2024-03-23 15:23                             ` Mathieu Desnoyers
2024-03-25 14:09                               ` Mathieu Desnoyers
2024-03-25 17:52                                 ` Adhemerval Zanella Netto
2024-03-24  0:59                             ` Cristian Rodríguez
2024-03-25  6:44                             ` Florian Weimer
2024-03-20 14:28         ` Wilco Dijkstra
2024-03-20 14:40           ` Xi Ruoyao
  -- strict thread matches above, loose matches on Subject: below --
2023-11-28 17:37 Wilco Dijkstra

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=6a938fb2-30a5-4589-9b58-10828823df6f@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=Jason@zx2c4.com \
    --cc=Wilco.Dijkstra@arm.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=cristian@rodriguez.im \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=zack@owlfolio.org \
    /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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).