From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 37124 invoked by alias); 8 Nov 2016 20:37:11 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 37014 invoked by uid 89); 8 Nov 2016 20:37:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=Hx-languages-length:1524, sk:getpid_, yarchive.net, getpid_caching.html X-HELO: mail-ua0-f181.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=+Mitzmx//WvhdpzYa8NHpEVDrL7DGWXdQU4b8wCL3Bs=; b=MiT6kbSv5cKdd8G5Ku+oNw15zW8mDuVPKK78kH3IX2dku8mQiPGfpbEFkN22cGtE18 SWtXjImBwmFbt2q++e272UExIQhMwkbFJt4QTnzmbC7Njd92Qm97TZQkh/FwaepoDG52 kOSfQGhEya1Dzq//pi7sYgt5Jbxg3MLxyYNYtsAj2PNXpQPlsPGTv6i3FMuPEMaCQOeN soglaaBGsLRVg4Y+fxUBlDrgitnpyNvZaOA0a7WUuVDjESj4ni2MjjDa+TQJoI2nheSp 89wfluHXfwVJg4oGK/NXe5lwPRvCz7TNEiwj/pSYPjCe714ClEmWee6ZK2rs+sKhgtrV BqVg== X-Gm-Message-State: ABUngvd0+bsXNbxz7Qvlush8uhQ8z0qFIsE2ravlbAo7RLjV/6Wm+6Pr1PzU+nQ8raVFTKaQ X-Received: by 10.176.4.12 with SMTP id 12mr9528013uav.81.1478637418467; Tue, 08 Nov 2016 12:36:58 -0800 (PST) Subject: Re: [PATCH] Remove cached PID/TID in clone To: Florian Weimer References: <1476387924-4509-1-git-send-email-adhemerval.zanella@linaro.org> <878tstu3yc.fsf@mid.deneb.enyo.de> Cc: libc-alpha@sourceware.org From: Adhemerval Zanella Message-ID: Date: Tue, 08 Nov 2016 20:37:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <878tstu3yc.fsf@mid.deneb.enyo.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-SW-Source: 2016-11/txt/msg00302.txt.bz2 On 08/11/2016 18:11, Florian Weimer wrote: > * 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; > } > > > > 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. > Right, I referenced a quite old discussion about the pid caching and the randomness provided by getpid [1]. And I think that an portable application like OpenSSL should not rely on an specific getpid implementation in a hotspot call, since on mostly implementations it will likely be a syscall. [1] http://yarchive.net/comp/linux/getpid_caching.html