This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Remove cached PID/TID in clone
- From: Florian Weimer <fw at deneb dot enyo dot de>
- To: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- Cc: libc-alpha at sourceware dot org
- Date: Tue, 08 Nov 2016 21:11:39 +0100
- Subject: Re: [PATCH] Remove cached PID/TID in clone
- Authentication-results: sourceware.org; auth=none
- References: <1476387924-4509-1-git-send-email-adhemerval.zanella@linaro.org> <c432ff40-edf2-1ebe-f3a7-de76fbfdd252@redhat.com> <d0b874df-d9f7-6121-6786-6ac1292a82ec@linaro.org>
* Adhemerval Zanella:
>> It's a hotspot for incorrect/broken fork detection.
>
> If you mean the assert on fork.c, I review the code and it seems
> unnecessary to remove the assert on child creation:
No, something else entirely. OpenSSL mixes the current PID into the
randomness pool, in an attempt to make sure that the streams generated
by parent and child are different:
pid_t curr_pid = getpid();
…
if (curr_pid) { /* just in the first iteration to save time */
if (!MD_Update(m, (unsigned char *)&curr_pid, sizeof curr_pid))
goto err;
curr_pid = 0;
}
<https://github.com/openssl/openssl/blob/master/crypto/rand/md_rand.c#L283>
This happens at every invocation of RAND_bytes. It may show up in
profiles if all the other system calls (time, gettimeofday etc.) are
handled by the vDSO.
But I suggest that this shouldn't block your change. It's just
something we should be aware of. If the kernel provides a more
efficient way to get the PID, we can change glibc to use it.
More comments about your revised patch tomorrow.