Issue 7022 - Patch - Mozilla NSS - NSS_Init* functions are not thread safe
Summary: Patch - Mozilla NSS - NSS_Init* functions are not thread safe
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-08-16 18:09 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-08-16 18:09:42 UTC
Full_Name: Rich Megginson
Version: current tip of master branch
OS: RHEL6
URL: ftp://ftp.openldap.org/incoming/0001-NSS_Init-functions-are-not-thread-safe.patch
Submission from: (NULL) (76.26.104.137)


The NSS_InitContext et. al, and their corresponding shutdown functions,
are not thread safe.  There can only be one thread at a time calling
these functions.  Protect the calls with a mutex.  Create the mutex
using a PR_CallOnce to ensure that the mutex is only created once and
not used before created.  Move the registration of the nss shutdown
callback to also use a PR_CallOnce.  Removed the call to
SSL_ClearSessionCache() because it is always called at shutdown, and we must
not call it more than once.

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-08-24 22:34:35 UTC
rmeggins@redhat.com wrote:
> Full_Name: Rich Megginson
> Version: current tip of master branch
> OS: RHEL6
> URL: ftp://ftp.openldap.org/incoming/0001-NSS_Init-functions-are-not-thread-safe.patch
> Submission from: (NULL) (76.26.104.137)
>
>
> The NSS_InitContext et. al, and their corresponding shutdown functions,
> are not thread safe.  There can only be one thread at a time calling
> these functions.  Protect the calls with a mutex.  Create the mutex
> using a PR_CallOnce to ensure that the mutex is only created once and
> not used before created.  Move the registration of the nss shutdown
> callback to also use a PR_CallOnce.  Removed the call to
> SSL_ClearSessionCache() because it is always called at shutdown, and we must
> not call it more than once.

We generally assume that all initialization is done before threads are 
spawned. I seem to recall this is a requirement for GnuTLS, anyway.

I've applied this patch but it has a few issues. E.g., the LDAP_MUTEX macros 
are already defined relative to LDAP_R_COMPILE so they do not need to be 
protected by ifdefs. In fact the macros are there specifically to eliminate 
all of those ifdefs.

A couple of whitespace strangenesses too. I'll fix these here, thanks for the 
patch.
>
> 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-08-24 22:38:25 UTC
changed notes
changed state Open to Test
moved from Incoming to Software Bugs
Comment 3 Quanah Gibson-Mount 2011-10-28 02:11:21 UTC
changed notes
changed state Test to Release
Comment 4 Quanah Gibson-Mount 2011-11-28 18:38:17 UTC
changed notes
changed state Release to Closed
Comment 5 OpenLDAP project 2014-08-01 21:04:38 UTC
fixed in master
fixed in RE24