Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Sep 2008 19:01:20 +0400
From:      Andrey Chernov <ache@nagual.pp.ru>
To:        Attilio Rao <attilio@freebsd.org>
Cc:        current@freebsd.org
Subject:   Re: Is fork() hook ever possible?
Message-ID:  <20080916150120.GA40087@nagual.pp.ru>
In-Reply-To: <3bbf2fe10809160753o7e5e8a78q7c6bd44c02bfd5c2@mail.gmail.com>
References:  <20080916140319.GA34447@nagual.pp.ru> <BBB443F5-042C-444E-A2F4-592B66FF2003@gid.co.uk> <20080916144502.GA39765@nagual.pp.ru> <3bbf2fe10809160753o7e5e8a78q7c6bd44c02bfd5c2@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Sep 16, 2008 at 04:53:54PM +0200, Attilio Rao wrote:
> 2008/9/16, Andrey Chernov <ache@nagual.pp.ru>:
> > On Tue, Sep 16, 2008 at 03:38:16PM +0100, Bob Bishop wrote:
> >  > Hi,
> >
> > >
> >  > On 16 Sep 2008, at 15:03, Andrey Chernov wrote:
> >  >
> >  > > I need some sort of fork() hook to detect that pid is changed to re-
> >  > > stir
> >  > > ar4random() after that (in the child), simple flag variable with
> >  > > child's pid is needed.
> >  > >
> >  > > Currently OpenBSD does almost that checking getpid() every time
> >  > > arc4random() called, but it is very slow way to use getpid() syscall
> >  > > repeatedly, about 12-15 times slower than just arc4random() without
> >  > > getpid().
> >  > >
> >  > > Any ideas?
> >  >
> >
> > > How about something hacky using mmap()/minherit()?
> >
> >  Could you please provide working low cost example to detect that we are in
> >  the child (pid changed or something else)? Calling getpid() as OpenBSD
> >  does definitely is very high cost. :(
> 
> An idea would be to implement a shared page between process and system
> which exports such informations.
> I'm sure we have a SoC project (2007) implementing this and perforce
> branches for it, I'm just not sure how far it did end.

Please keep in mind that the hook itself must be invisible to user 
application, we have standard API only - fork() and arc4random() family, 
no additional setup or functions are possible outside of existen API. I.e. 
the low cost hack must be completely inside ether the fork() wrapper or 
arc4random().

-- 
http://ache.pp.ru/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080916150120.GA40087>