Bug 1193243

Summary: ldbm_usn_init: Valgrind reports Invalid read / SIGSEGV
Product: Red Hat Enterprise Linux 6 Reporter: Noriko Hosoi <nhosoi>
Component: 389-ds-baseAssignee: Noriko Hosoi <nhosoi>
Status: CLOSED ERRATA QA Contact: Viktor Ashirov <vashirov>
Severity: high Docs Contact:
Priority: high    
Version: 6.0CC: msauton, nhosoi, nkinder, rmeggins
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 389-ds-base-1.2.11.15-51.el6 Doc Type: Bug Fix
Doc Text:
When there was a suffix with no backend database associated, the server did not start due to the segmentation fault in ldbm_usn_init. The bug was fixed and the server starts.
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-07-22 06:37:00 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
valgrind output none

Description Noriko Hosoi 2015-02-16 23:45:52 UTC
This bug is created as a clone of upstream ticket:
https://fedorahosted.org/389/ticket/47659

==26183==
==26183== Invalid read of size 8
==26183==    at 0xFF0E29C: ldbm_usn_init (ldbm_usn.c:83)
==26183==    by 0xFF20786: ldbm_back_start (start.c:300)
==26183==    by 0x4CC34E3: plugin_call_func (plugin.c:1474)
==26183==    by 0x4CC33D0: plugin_call_one (plugin.c:1442)
==26183==    by 0x4CC2BE1: plugin_dependency_startall (plugin.c:1214)
==26183==    by 0x4CC3302: plugin_startall (plugin.c:1404)
==26183==    by 0x12F3CA: main (main.c:1187)
==26183==  Address 0x80 is not stack'd, malloc'd or (recently) free'd
==26183==
==26183==
==26183== Process terminating with default action of signal 11 (SIGSEGV)
==26183==  Access not within mapped region at address 0x80
==26183==    at 0xFF0E29C: ldbm_usn_init (ldbm_usn.c:83)
==26183==    by 0xFF20786: ldbm_back_start (start.c:300)
==26183==    by 0x4CC34E3: plugin_call_func (plugin.c:1474)
==26183==    by 0x4CC33D0: plugin_call_one (plugin.c:1442)
==26183==    by 0x4CC2BE1: plugin_dependency_startall (plugin.c:1214)
==26183==    by 0x4CC3302: plugin_startall (plugin.c:1404)
==26183==    by 0x12F3CA: main (main.c:1187)
==26183==  If you believe this happened as a result of a stack
==26183==  overflow in your program's main thread (unlikely but
==26183==  possible), you can try to increase the size of the
==26183==  main thread stack using the --main-stacksize= flag.
==26183==  The main thread stack size used in this run was 8388608.
==26183==

 62 void
 63 ldbm_usn_init(struct ldbminfo  *li)
    ...
 79     /* Search each namingContext in turn */
 80     for ( sdn = slapi_get_first_suffix( &node, 0 ); sdn != NULL;
 81           sdn = slapi_get_next_suffix_ext( &node, 0 )) {
 82         be = slapi_mapping_tree_find_backend_for_sdn(sdn);
 83         slapi_log_error(SLAPI_LOG_BACKLDBM, "ldbm_usn_init",
 84                     "backend: %s%s\n", be->be_name, isglobal?" (global mode)":""); <== crashed here; slapi_mapping_tree_find_backend_for_sdn returned 0x80?

Comment 1 Jenny Severance 2015-02-17 10:56:48 UTC
please add steps to reproduce and verify this issue

Comment 2 Noriko Hosoi 2015-02-17 22:01:54 UTC
Steps to verify:
1. create a suffix mapping tree without backend.  E.g.,
ldapmodify -a ... << EOF
dn: cn=dc\3Dnew\2Cdc\3Dcom,cn=mapping tree,cn=config
objectClass: top
objectClass: extensibleObject
objectClass: nsMappingTree
nsslapd-state: Disabled
cn: dc=new,dc=com
EOF

2. enable the LDAP_DEBUG_BACKLDBM log level:
nsslapd-errorlog-level: 524288

3. Start ns-slapd via valgrind

4. If no invalid read error indicating ldbm_usn_init, the bug was verified.
==26183== Invalid read of size 8
==26183==    at 0xFF0E29C: ldbm_usn_init (ldbm_usn.c:83)
...

Comment 3 Noriko Hosoi 2015-02-19 01:50:34 UTC
*** Bug 1166460 has been marked as a duplicate of this bug. ***

Comment 5 Viktor Ashirov 2015-03-15 21:22:56 UTC
Created attachment 1002048 [details]
valgrind output

Build tested:
389-ds-base-1.2.11.15-52.el6.x86_64
389-ds-base-libs-1.2.11.15-52.el6.x86_64

No mentions of ldbm_usn_init in the valgrind output.

Marking as VERIFIED.

Comment 6 errata-xmlrpc 2015-07-22 06:37:00 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-1326.html