Issue 6811 - Patch - Mozilla NSS - disable pkcs11 fork checking for the software token
Summary: Patch - Mozilla NSS - disable pkcs11 fork checking for the software token
Status: VERIFIED FIXED
Alias: None
Product: OpenLDAP
Classification: Unclassified
Component: slapd (show other issues)
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-28 15:34 UTC by rich.megginson@gmail.com
Modified: 2014-08-01 21:04 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description rich.megginson@gmail.com 2011-01-28 15:34:01 UTC
Full_Name: Rich Megginson
Version: 2.4.23 (current CVS HEAD)
OS: RHEL6
URL: ftp://ftp.openldap.org/incoming/openldap-2.4.23-moznss-disable-nofork-20110127.patch
Submission from: (NULL) (76.113.111.209)


There are some applications that acquire a crypto context in the parent process
and expect that crypto context to work after a fork().  This does not work
with MozNSS using strict PKCS11 compliance mode.  We set the environment
variable NSS_STRICT_NOFORK=DISABLED in tlsm_init() to tell the software
encryption module/token to allow crypto contexts to persist across a fork(). 
However, if you are using some other module or encryption device that supports
and expects full PKCS11 semantics, the only recourse is to modify the
application to use atfork() handlers to save the crypto context in the parent
and restore (and SECMOD_RestartModules) the context in the child.

These patch files are derived from OpenLDAP Software. All of the
modifications to OpenLDAP Software represented in the following
patch(es) were developed by Red Hat. Red Hat has not assigned rights
and/or interest in this work to any party. I, Rich Megginson am
authorized by Red Hat, my employer, to release this work under the
following terms.

Red Hat hereby place the following modifications to OpenLDAP Software
(and only these modifications) into the public domain. Hence, these
modifications may be freely used and/or redistributed for any purpose
with or without attribution and/or other notice.
Comment 1 Howard Chu 2011-01-29 10:25:46 UTC
rmeggins@redhat.com wrote:
> Full_Name: Rich Megginson
> Version: 2.4.23 (current CVS HEAD)
> OS: RHEL6
> URL: ftp://ftp.openldap.org/incoming/openldap-2.4.23-moznss-disable-nofork-20110127.patch
> Submission from: (NULL) (76.113.111.209)
>
>
> There are some applications that acquire a crypto context in the parent process
> and expect that crypto context to work after a fork().  This does not work
> with MozNSS using strict PKCS11 compliance mode.  We set the environment
> variable NSS_STRICT_NOFORK=DISABLED in tlsm_init() to tell the software
> encryption module/token to allow crypto contexts to persist across a fork().
> However, if you are using some other module or encryption device that supports
> and expects full PKCS11 semantics, the only recourse is to modify the
> application to use atfork() handlers to save the crypto context in the parent
> and restore (and SECMOD_RestartModules) the context in the child.

Sounds like this is a followon to #6802. Is this really critical at this 
point? We really need to close the window on RE24 patches so we can actually 
cut a release. But if ITS#6802 is actually incomplete, I guess we should roll 
this in.

> These patch files are derived from OpenLDAP Software. All of the
> modifications to OpenLDAP Software represented in the following
> patch(es) were developed by Red Hat. Red Hat has not assigned rights
> and/or interest in this work to any party. I, Rich Megginson am
> authorized by Red Hat, my employer, to release this work under the
> following terms.
>
> Red Hat hereby place the following modifications to OpenLDAP Software
> (and only these modifications) into the public domain. Hence, these
> modifications may be freely used and/or redistributed for any purpose
> with or without attribution and/or other notice.
>


-- 
   -- Howard Chu
   CTO, Symas Corp.           http://www.symas.com
   Director, Highland Sun     http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP  http://www.openldap.org/project/

Comment 2 Howard Chu 2011-01-29 11:41:05 UTC
changed notes
changed state Open to Test
moved from Incoming to Software Bugs
Comment 3 rich.megginson@gmail.com 2011-01-29 17:18:27 UTC
On Sat, Jan 29, 2011 at 3:26 AM,  <hyc@symas.com> wrote:
> rmeggins@redhat.com wrote:
>> Full_Name: Rich Megginson
>> Version: 2.4.23 (current CVS HEAD)
>> OS: RHEL6
>> URL: ftp://ftp.openldap.org/incoming/openldap-2.4.23-moznss-disable-nofork-20110127.patch
>> Submission from: (NULL) (76.113.111.209)
>>
>>
>> There are some applications that acquire a crypto context in the parent process
>> and expect that crypto context to work after a fork().  This does not work
>> with MozNSS using strict PKCS11 compliance mode.  We set the environment
>> variable NSS_STRICT_NOFORK=DISABLED in tlsm_init() to tell the software
>> encryption module/token to allow crypto contexts to persist across a fork().
>> However, if you are using some other module or encryption device that supports
>> and expects full PKCS11 semantics, the only recourse is to modify the
>> application to use atfork() handlers to save the crypto context in the parent
>> and restore (and SECMOD_RestartModules) the context in the child.
>
> Sounds like this is a followon to #6802. Is this really critical at this
> point? We really need to close the window on RE24 patches so we can actually
> cut a release. But if ITS#6802 is actually incomplete, I guess we should roll
> this in.

Yes, it is a followon to 6802 - as it turns out, the patch to 6802 was
incomplete.  We have discovered some important applications such as
sshd/su/others that open an LDAP* connection in the parent process,
fork(), and attempt to use the same LDAP* handle in the child.  Some
of the other Fedora/Red Hat developers and I had a discussion with one
of the MozNSS developers about this issue, as ldap is not the only
affected area.  It was decided that the best thing is to simply
disable the fork() checking in the MozNSS software token pkcs11 crypto
module.  This will give us parity with openssl with respect to fork()
behavior.  It is a critical issue for Fedora/Red Hat.  I understand
that this is coming in late in the game and you may not be able to get
this into RE24.  If not, Fedora/Red Hat will carry a patch for this.

>
>> These patch files are derived from OpenLDAP Software. All of the
>> modifications to OpenLDAP Software represented in the following
>> patch(es) were developed by Red Hat. Red Hat has not assigned rights
>> and/or interest in this work to any party. I, Rich Megginson am
>> authorized by Red Hat, my employer, to release this work under the
>> following terms.
>>
>> Red Hat hereby place the following modifications to OpenLDAP Software
>> (and only these modifications) into the public domain. Hence, these
>> modifications may be freely used and/or redistributed for any purpose
>> with or without attribution and/or other notice.
>>
>
>
> --
>   -- Howard Chu
>   CTO, Symas Corp.           http://www.symas.com
>   Director, Highland Sun     http://highlandsun.com/hyc/
>   Chief Architect, OpenLDAP  http://www.openldap.org/project/
>
>
>

Comment 4 Howard Chu 2011-01-29 19:39:14 UTC
richm@stanfordalumni.org wrote:
> On Sat, Jan 29, 2011 at 3:26 AM,<hyc@symas.com>  wrote:
>> rmeggins@redhat.com wrote:
>>> Full_Name: Rich Megginson
>>> Version: 2.4.23 (current CVS HEAD)
>>> OS: RHEL6
>>> URL: ftp://ftp.openldap.org/incoming/openldap-2.4.23-moznss-disable-nofo=
> rk-20110127.patch
>>> Submission from: (NULL) (76.113.111.209)
>>>
>>>
>>> There are some applications that acquire a crypto context in the parent =
> process
>>> and expect that crypto context to work after a fork(). =A0This does not =
> work
>>> with MozNSS using strict PKCS11 compliance mode. =A0We set the environme=
> nt
>>> variable NSS_STRICT_NOFORK=3DDISABLED in tlsm_init() to tell the softwar=
> e
>>> encryption module/token to allow crypto contexts to persist across a for=
> k().
>>> However, if you are using some other module or encryption device that su=
> pports
>>> and expects full PKCS11 semantics, the only recourse is to modify the
>>> application to use atfork() handlers to save the crypto context in the p=
> arent
>>> and restore (and SECMOD_RestartModules) the context in the child.
>>
>> Sounds like this is a followon to #6802. Is this really critical at this
>> point? We really need to close the window on RE24 patches so we can actua=
> lly
>> cut a release. But if ITS#6802 is actually incomplete, I guess we should =
> roll
>> this in.
>
> Yes, it is a followon to 6802 - as it turns out, the patch to 6802 was
> incomplete.  We have discovered some important applications such as
> sshd/su/others that open an LDAP* connection in the parent process,
> fork(), and attempt to use the same LDAP* handle in the child.  Some
> of the other Fedora/Red Hat developers and I had a discussion with one
> of the MozNSS developers about this issue, as ldap is not the only
> affected area.  It was decided that the best thing is to simply
> disable the fork() checking in the MozNSS software token pkcs11 crypto
> module.  This will give us parity with openssl with respect to fork()
> behavior.  It is a critical issue for Fedora/Red Hat.  I understand
> that this is coming in late in the game and you may not be able to get
> this into RE24.  If not, Fedora/Red Hat will carry a patch for this.

Is this env var and atfork() workaround already documented in the NSS 
documentation? Just wondering if we need to say anything about it in our Admin 
Guide, FAQ-o-Matic, or manpages.

-- 
   -- Howard Chu
   CTO, Symas Corp.           http://www.symas.com
   Director, Highland Sun     http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP  http://www.openldap.org/project/

Comment 5 rich.megginson@gmail.com 2011-01-29 22:04:45 UTC
The NSS_STRICT_NOFORK environment variable is documented here:
https://developer.mozilla.org/en/NSS_reference/NSS_environment_variables

Note that if a user really wants the strict pkcs11 behavior, the user
can set the variable to "1" or some other non-empty value (other than
"DISABLED").

If you think further documentation is required, I would be happy to
update the Admin Guide, FAQ-o-matic, man pages, etc.

Comment 6 Howard Chu 2011-01-29 22:30:52 UTC
richm@stanfordalumni.org wrote:
> The NSS_STRICT_NOFORK environment variable is documented here:
> https://developer.mozilla.org/en/NSS_reference/NSS_environment_variables
>
> Note that if a user really wants the strict pkcs11 behavior, the user
> can set the variable to "1" or some other non-empty value (other than
> "DISABLED").
>
> If you think further documentation is required, I would be happy to
> update the Admin Guide, FAQ-o-matic, man pages, etc.

That looks fine. Most of our docs were written specifically to OpenSSL but 
we've added one or two references to GnuTLS since then. I would start by 
adding to the FAQ-o-Matic:

http://www.openldap.org/faq/data/cache/196.html

I guess we could update this to mention the availability of GnuTLS and MozNSS 
support and perhaps a discussion of their pros and cons. (Though in all 
honesty I cannot think of any pros for using GnuTLS. I would use PolarSSL 
instead but that's not what the Debian folks asked for...)

Hm, this entire FAQ page is far out of date. If you want to add some MozNSS 
info here go ahead, I'll take a pass at the rest of the page later.
-- 
   -- Howard Chu
   CTO, Symas Corp.           http://www.symas.com
   Director, Highland Sun     http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP  http://www.openldap.org/project/

Comment 7 Quanah Gibson-Mount 2011-01-31 11:23:01 UTC
changed notes
changed state Test to Release
Comment 8 Quanah Gibson-Mount 2011-02-14 12:43:46 UTC
changed notes
changed state Release to Closed
Comment 9 OpenLDAP project 2014-08-01 21:04:34 UTC
part of #6802. added to HEAD
added to RE24