All of lore.kernel.org
 help / color / mirror / Atom feed
* Ideas on NSS vs fork?
@ 2011-04-28 21:29 Tommi Virtanen
  2011-04-29  6:02 ` Colin Patrick McCabe
  0 siblings, 1 reply; 5+ messages in thread
From: Tommi Virtanen @ 2011-04-28 21:29 UTC (permalink / raw)
  To: ceph-devel

NSS, the crypto library Red Hat likes to use, cannot tolerate
forks. NSS_NoDB_Init must be called after daemonization, and there
seems to be no way around it; for example, calling it again is
explicitly forbidden.

The code in branch wip-nss-vs-fork adds a common_init_daemonized
function, that things that (potentially) daemonize must call, after
the point where they'd daemonize. Non-daemons are handled in
common_preinit and need nothing special.

Users of libceph/librados cannot fork, and expect to keep using the
library :(

The "remove this" comment on libceph_initialized cannot be blindly
acted on; similar logic could be pushed down into ceph::crypto::init,
though.

This is ugly, but it's the best I could do. Please go through the code
and let me know if you have any ideas on how to make it less painful.

In the meanwhile, if you need NSS to work, you can always run in
non-daemonizing mode, with -f.


P.S. Please use Crypto++. For my sanity.

-- 
:(){ :|:&};:

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Ideas on NSS vs fork?
  2011-04-28 21:29 Ideas on NSS vs fork? Tommi Virtanen
@ 2011-04-29  6:02 ` Colin Patrick McCabe
  2011-04-29 15:49   ` Sage Weil
  2011-04-29 16:14   ` Tommi Virtanen
  0 siblings, 2 replies; 5+ messages in thread
From: Colin Patrick McCabe @ 2011-04-29  6:02 UTC (permalink / raw)
  To: Tommi Virtanen; +Cc: ceph-devel

On Thu, Apr 28, 2011 at 2:29 PM, Tommi Virtanen
<tommi.virtanen@dreamhost.com> wrote:
> NSS, the crypto library Red Hat likes to use, cannot tolerate
> forks. NSS_NoDB_Init must be called after daemonization, and there
> seems to be no way around it; for example, calling it again is
> explicitly forbidden.
>
> The code in branch wip-nss-vs-fork adds a common_init_daemonized
> function, that things that (potentially) daemonize must call, after
> the point where they'd daemonize. Non-daemons are handled in
> common_preinit and need nothing special.
>
> Users of libceph/librados cannot fork, and expect to keep using the
> library :(

We already are in a situation where the child process after a fork
can't use librados or libceph. The reason is because the child process
will not have any threads besides the main one.

The question we need to answer is really whether forking somehow
destroys the state of the parent process, even if the child thread
never runs any libNSS code. If the answer is no, which is very likely,
then essentially our situation is unchanged.

>
> The "remove this" comment on libceph_initialized cannot be blindly
> acted on; similar logic could be pushed down into ceph::crypto::init,
> though.
>
> This is ugly, but it's the best I could do. Please go through the code
> and let me know if you have any ideas on how to make it less painful.

Daemonization should be done in common_init. Obviously, only daemons will do it!

Daemonization has nothing to do with the messenger logically, so it
will be good to get that stuff out of there.

Colin.

>
> In the meanwhile, if you need NSS to work, you can always run in
> non-daemonizing mode, with -f.
>
>
> P.S. Please use Crypto++. For my sanity.
>
> --
> :(){ :|:&};:
> --
> To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Ideas on NSS vs fork?
  2011-04-29  6:02 ` Colin Patrick McCabe
@ 2011-04-29 15:49   ` Sage Weil
  2011-04-29 16:14   ` Tommi Virtanen
  1 sibling, 0 replies; 5+ messages in thread
From: Sage Weil @ 2011-04-29 15:49 UTC (permalink / raw)
  To: Colin Patrick McCabe; +Cc: Tommi Virtanen, ceph-devel

On Thu, 28 Apr 2011, Colin Patrick McCabe wrote:
> > The "remove this" comment on libceph_initialized cannot be blindly
> > acted on; similar logic could be pushed down into ceph::crypto::init,
> > though.
> >
> > This is ugly, but it's the best I could do. Please go through the code
> > and let me know if you have any ideas on how to make it less painful.
> 
> Daemonization should be done in common_init. Obviously, only daemons 
> will do it!

Well, probably after that.  There is a lot of initialization that 
intentionally runs before daemonization (so that you get feedback on 
errors, etc.).

> Daemonization has nothing to do with the messenger logically, so it
> will be good to get that stuff out of there.

Yeah.  SimpleMessenger::start() basically does some checks, forks, and 
then starts a thread.  The forking bit can be moved out, and I think most 
of the checks are obsolete anyway.

sage

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Ideas on NSS vs fork?
  2011-04-29  6:02 ` Colin Patrick McCabe
  2011-04-29 15:49   ` Sage Weil
@ 2011-04-29 16:14   ` Tommi Virtanen
  2011-04-29 16:15     ` Tommi Virtanen
  1 sibling, 1 reply; 5+ messages in thread
From: Tommi Virtanen @ 2011-04-29 16:14 UTC (permalink / raw)
  To: Colin Patrick McCabe; +Cc: ceph-devel

On Thu, Apr 28, 2011 at 11:02:57PM -0700, Colin Patrick McCabe wrote:
> The question we need to answer is really whether forking somehow
> destroys the state of the parent process, even if the child thread
> never runs any libNSS code. If the answer is no, which is very likely,
> then essentially our situation is unchanged.

For NSS, only the pid that ran ceph::crypto::init() has a working
crypto library.

1. If you init before forking, any forked processes will have their
   NSS return errors, with no way to fix that. The parent keeps
   working.

2. If you init after forking, the parent never even tries to init crypto,
   the child does and gets a perfectly working crypto library.

2b. As an extension of above, the parent *could* init crypto after it
    has already forked off the child. We just have no need for that.


None of these make it possible for the child to wreck the NSS state in
the parent.

(The Ceph daemons before commit c9825f08 follow #1, that commits makes
them follow #2.)

-- 
:(){ :|:&};:

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Ideas on NSS vs fork?
  2011-04-29 16:14   ` Tommi Virtanen
@ 2011-04-29 16:15     ` Tommi Virtanen
  0 siblings, 0 replies; 5+ messages in thread
From: Tommi Virtanen @ 2011-04-29 16:15 UTC (permalink / raw)
  To: Colin Patrick McCabe; +Cc: ceph-devel

On Fri, Apr 29, 2011 at 09:14:24AM -0700, Tommi Virtanen wrote:
> (The Ceph daemons before commit c9825f08 follow #1, that commits makes
> them follow #2.)

I mean 6eb7e1c0dc6ca6df7e59f813f392a50c728b474e, in branch
wip-nss-vs-fork currently.

-- 
:(){ :|:&};:

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-04-29 16:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-28 21:29 Ideas on NSS vs fork? Tommi Virtanen
2011-04-29  6:02 ` Colin Patrick McCabe
2011-04-29 15:49   ` Sage Weil
2011-04-29 16:14   ` Tommi Virtanen
2011-04-29 16:15     ` Tommi Virtanen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.