Bug 1433697

Summary: Double free in _ldap/servers/plugins/replication/cl5_api.c:cl5NewDBFile()
Product: Red Hat Enterprise Linux 7 Reporter: mreynolds
Component: 389-ds-baseAssignee: mreynolds
Status: CLOSED ERRATA QA Contact: Viktor Ashirov <vashirov>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.4CC: nkinder, rmeggins
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 389-ds-base-1.3.6.1-4.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1433703 (view as bug list) Environment:
Last Closed: 2017-08-01 21:14:10 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:
Bug Depends On:    
Bug Blocks: 1433703    

Description mreynolds 2017-03-19 12:07:55 UTC
This bug is created as a clone of upstream ticket:
https://pagure.io/389-ds-base/issue/49175

#### Issue Description
When fixing our freeipa cluster & redeploying of some replicas, I hit strange ns-slapd crashes. After little debugging & ASANning, I nailed down double-free in cl5NewDBFile error path. Patch is attached, feel free to ask me if you need more info.

#### Package Version and Platform
CentOS 7.2

$ rpm -q 389-ds-base
389-ds-base-1.3.5.10-11.x86_64

#### Steps to reproduce

1. Fill IPC semaphore table (/usr/bin/ipcs) - in my case all available semaphores were consumed by httpd
2. Try to setup replication (I installed FreeIPA replica)

#### Actual results
Crash:
$ dmesg -T
[Sat Mar 18 20:59:31 2017] traps: ns-slapd[3454] general protection ip:7f2fa2f08abd sp:7f2f787ef560 error:0 in libc-2.17.so[7f2fa2e8d000+1b7000]

#### Expected results
ns-slapd shouldn't crash, it should write errors to the log.


Fixed upstream

Comment 2 mreynolds 2017-03-21 20:15:00 UTC
Fixed upstream

Comment 3 mreynolds 2017-03-23 14:24:09 UTC
*** Bug 1433703 has been marked as a duplicate of this bug. ***

Comment 5 Viktor Ashirov 2017-05-20 19:10:51 UTC
Build tested:
389-ds-base-1.3.6.1-14.el7.x86_64

[1] Exhaust available semaphores:
# for i in $(seq 1 $(awk '{print $NF}' /proc/sys/kernel/sem)); do ipcmk -S 1; done

[2] Run replication test:
# py.test -s -v  /export/tests/suites/replication/acceptance_test.py::test_add_entry

Expectedly test fails, because server fails to create semaphore: 

May 20 15:01:57 XXX ns-slapd[13260]: [20/May/2017:15:01:57.577477095 -0400] - ERR - NSMMReplicationPlugin - changelog program - _cl5NewDBFile - Failed to create semaphore /var/lib/dirsrv/slapd-master_2/changelogdb/97d41bc5-3d8e11e7-93918b95-29c229d4.sema; NSPR error - -5956

But it doesn't crash. Marking as VERIFIED.

Comment 6 errata-xmlrpc 2017-08-01 21:14:10 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://access.redhat.com/errata/RHBA-2017:2086