git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] wrapper: add a helper to generate numbers from a CSPRNG

From
Taylor Blau <me@ttaylorr.com>
Date
Nov 16, 2021, 18:22 UTC
Message-ID
<YZP3ApaDcMGIsKeb@nand.local>
In-Reply-To
<009d01d7db03$354ecae0$9fec60a0$@nexbridge.com>
On Tue, Nov 16, 2021 at 11:01:20AM -0500, rsbecker@nexbridge.com wrote:
Show 30 quoted lines
> On November 16, 2021 10:31 AM, Jeff King wrote:
> > On Tue, Nov 16, 2021 at 03:35:41AM +0000, brian m. carlson wrote:
> >
> > > The order of options is also important here.  On systems with
> > > arc4random, which is most of the BSDs, we use that, since, except on
> > > MirBSD, it uses ChaCha20, which is extremely fast, and sits entirely
> > > in userspace, avoiding a system call.  We then prefer getrandom over
> > > getentropy, because the former has been available longer on Linux, and
> > > finally, if none of those are available, we use /dev/urandom, because
> > > most Unix-like operating systems provide that API.  We prefer options
> > > that don't involve device files when possible because those work in
> > > some restricted environments where device files may not be available.
> >
> > I wonder if we'll need a low-quality fallback for older systems which don't
> > even have /dev/urandom. Because it's going to be used in such a core part of
> > the system (tempfiles), this basically becomes a hard requirement for using
> > Git at all.
> >
> > I can't say I'm excited in general to be introducing a dependency like this, just
> > because of the portability headaches. But it may be the least bad thing
> > (especially if we can fall back to the existing behavior).
> > One alternative would be to build on top of the system mkstemp(), which
> > makes it libc's problem. I'm not sure if we'd run into problems there, though.
>
> None of /dev/urandom, /dev/random, or mkstemp are available on some
> platforms, including NonStop. This is not a good dependency to add.
> One variant PRNGD is used in ia64 OpenSSL, while the CPU random
> generator in hardware is used on x86. I cannot get behind this at all.
> Libc is also not used in or available to our port. I am very worried
> about this direction.

I share Peff's lack of enthusiasm about the dependency situation. But making Git depend on having /dev/urandom available is simply not feasible, as you point out.

I wonder if the suitable fall-back should be the existing behavior of git_mkstemps_mode()? That leaves us in a somewhat-disappointing situation of not having fully resolved the DOS attack on all platforms. But it makes our dependency situation less complicated, and leaves things no worse off than the were before on platforms like NonStop.

Thanks, Taylor

Previous: rsbecker@nexbridge.comNext: rsbecker@nexbridge.com
Message 11 of 37 in “Generate temporary files using a CSPRNG”
  1. 0/2 Generate temporary files using a CSPRNGbrian m. carlson, Nov 16, 2021
  2. 2/2 wrapper: use a CSPRNG to generate random file namesbrian m. carlson, Nov 16, 2021
  3. Jeff KingNov 16, 2021
  4. Taylor BlauNov 16, 2021
  5. Junio C HamanoNov 16, 2021
  6. Jeff KingNov 16, 2021
  7. Taylor BlauNov 16, 2021
  8. 1/2 wrapper: add a helper to generate numbers from a CSPRNGbrian m. carlson, Nov 16, 2021
  9. Jeff KingNov 16, 2021
  10. rsbecker@nexbridge.comNov 16, 2021
  11. Taylor BlauNov 16, 2021
  12. rsbecker@nexbridge.comNov 16, 2021
  13. brian m. carlsonNov 16, 2021
  14. rsbecker@nexbridge.comNov 16, 2021
  15. Carlo ArenasNov 17, 2021
  16. rsbecker@nexbridge.comNov 17, 2021
  17. brian m. carlsonNov 17, 2021
  18. Carlo ArenasNov 17, 2021
  19. Jeff KingNov 17, 2021
  20. rsbecker@nexbridge.comNov 17, 2021
  21. Carlo ArenasNov 17, 2021
  22. Jeff KingNov 17, 2021
  23. rsbecker@nexbridge.comNov 17, 2021
  24. brian m. carlsonNov 17, 2021
  25. rsbecker@nexbridge.comNov 17, 2021
  26. rsbecker@nexbridge.comNov 17, 2021
  27. Junio C HamanoNov 17, 2021
  28. brian m. carlsonNov 17, 2021
  29. Junio C HamanoNov 18, 2021
  30. brian m. carlsonNov 18, 2021
  31. Junio C HamanoNov 22, 2021
  32. Jeff KingNov 16, 2021
  33. brian m. carlsonNov 16, 2021
  34. rsbecker@nexbridge.comNov 16, 2021
  35. Ævar Arnfjörð BjarmasonNov 16, 2021
  36. Jeff KingNov 16, 2021
  37. Ævar Arnfjörð BjarmasonNov 17, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.