[PATCH 2/2] Use getrandom on try_tempname_len [BZ #15813]

Jakub Jelinek jakub@redhat.com
Thu Sep 10 21:57:27 GMT 2020


On Thu, Sep 10, 2020 at 06:53:27PM -0300, Adhemerval Zanella wrote:
> On 10/09/2020 18:21, Paul Eggert wrote:
> >>> As I wrote in bugzilla, I think it would be better to use clock_gettime64 ^
> >>> pid based "random" source for the initial randomness value, so that it
> >>> wouldn't deplete the random entropy pool, and use it only for the retries
> >>> (so only in the unlikely case the file exists already).
> > 
> > Isn't part of the goal to avoid collisions even in the first try, to avoid attacks by name-guessers on not-so-well-written callers? If so, we should use getrandom even for the first try (with GRND_NONBLOCK of course).
> > 
> > Generating a file name ought to be a reasonably-rare action,

For some programs like gcc, it is certainly not a rare action, it can create
thousands of them e.g. with LTO.
So not wasting time and entropy in the common case seems desirable to me.

> and I wouldn't worry too much about entropy pool exhaustion from such a small request.

	Jakub



More information about the Libc-alpha mailing list