From owner-freebsd-current@FreeBSD.ORG Wed Sep 17 08:05:00 2008 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A8841106567D; Wed, 17 Sep 2008 08:05:00 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) by mx1.freebsd.org (Postfix) with ESMTP id 6DEB68FC1D; Wed, 17 Sep 2008 08:05:00 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (unknown [192.168.61.3]) by phk.freebsd.dk (Postfix) with ESMTP id D4314170E4; Wed, 17 Sep 2008 08:04:58 +0000 (UTC) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.14.2/8.14.2) with ESMTP id m8H84vUh089507; Wed, 17 Sep 2008 08:04:57 GMT (envelope-from phk@critter.freebsd.dk) To: Andrey Chernov From: "Poul-Henning Kamp" In-Reply-To: Your message of "Wed, 17 Sep 2008 11:55:13 +0400." <20080917075513.GB55535@nagual.pp.ru> Date: Wed, 17 Sep 2008 08:04:57 +0000 Message-ID: <89506.1221638697@critter.freebsd.dk> Sender: phk@critter.freebsd.dk Cc: Daniel Eischen , Max Laier , freebsd-current@freebsd.org Subject: Re: Is fork() hook ever possible? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Sep 2008 08:05:00 -0000 In message <20080917075513.GB55535@nagual.pp.ru>, Andrey Chernov writes: >On Tue, Sep 16, 2008 at 08:41:33PM +0000, Poul-Henning Kamp wrote: >> In message <200809161628.54085.jhb@freebsd.org>, John Baldwin writes: >> >> >The PID isn't the seed, he's using a PID change as a notification that the >> >process needs to do a re-stir the next time it wants a psuedo-random number >> >(b/c the PID change means it is now a new process). >> >> Seems to be a vast overkill to me, in countless other contexts, >> it is the responsibility of the programmer to do what needs done on >> a fork, and I see no reason why this couldn't be likewise. > >The situation is not so simple since the library functions can call >ar4random() internally (like mktemp() family already and always does) I have a really hard time seeing how this could become a performance issue, ever. The solution however, is simple: Just have these hidden library calls to arc4random call a wrapper function that does the pid check. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.