Bug 875862

Summary: crash in DNA if no dnamagicregen is specified
Product: Red Hat Enterprise Linux 6 Reporter: Nathan Kinder <nkinder>
Component: 389-ds-baseAssignee: Rich Megginson <rmeggins>
Status: CLOSED ERRATA QA Contact: Sankar Ramalingam <sramling>
Severity: unspecified Docs Contact:
Priority: medium    
Version: 6.4CC: jgalipea, jrusnack, mreynolds, nhosoi
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 389-ds-base-1.2.11.15-4.el6 Doc Type: Bug Fix
Doc Text:
Cause: The DNA plugin attempts to dereference a NULL pointer value for the dnaMagicRegen attribute. Consequence: If DNA is enabled and no dnamagicregen is specified in the DNA configuration, and an entry is added that has an attribute that triggers the DNA value generation, the server could crash. Fix: Check for an empty dnamagicregen value before attempting to dereference it. Result: The server does not crash with no dnamagicregen is specified.
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-02-21 08:21:26 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: 881827    

Description Nathan Kinder 2012-11-12 17:18:36 UTC
This bug is created as a clone of upstream ticket:
https://fedorahosted.org/389/ticket/517

If you have a DNA configuration to provide values for a given attribute, but do not specify the dnamagicregen attribute and value, and you attempt to add/modify that given attribute, the server will crash in _dna_pre_op_modify():
{{{
                        /* If we have a value, see if it's the magic value. */
                        if (bv) {
                            len = strlen(config_entry->generate);
                            if (len == bv->bv_len) {
                                if (!slapi_UTF8NCASECMP(bv->bv_val,
                                                        config_entry->generate,
                                                        len)) {
                                    slapi_ch_array_add(&types_to_generate,
                                                       slapi_ch_strdup(type));
                                }
                            }
}}}

because the server does not first check if config_entry->generate is NULL before doing the strlen.

Comment 2 Sankar Ramalingam 2013-01-28 09:03:56 UTC
Request you to please add steps to Verify.

Comment 3 Noriko Hosoi 2013-01-28 16:36:56 UTC
(In reply to comment #2)
> Request you to please add steps to Verify.

Mark, could you provide the steps?  Thanks!

Comment 4 mreynolds 2013-01-29 15:22:09 UTC
This is an easy one.

To reproduce:

[1]  Setup the DNA plugin, but do NOT set "dnamagicregen"
[2]  Make an update that would trigger the DNA plugin to update an entry.
[3]  Server crashes.

Comment 5 Ján Rusnačko 2013-01-30 10:10:53 UTC
[jrusnack@dstet ~]$ ldapsearch -h localhost -p 22222 -D "cn=directory manager " -w Secret123 -b "cn=uidNumber,cn=Distributed Numeric Assignment Plugin,cn=plugins,cn=config" -LL
version: 1

dn: cn=uidNumber,cn=Distributed Numeric Assignment Plugin,cn=plugins,cn=config
objectClass: top
objectClass: extensibleObject
cn: uidNumber
dnaType: uidNumber
dnaNextValue: 2
dnaMaxValue: 1300
dnaThreshold: 200
dnaFilter: (objectClass=posixAccount)
dnaScope: ou=people,o=my.com

[jrusnack@dstet ~]$ ldapmodify  -h localhost -p 22222 -D "cn=directory manager " -w Secret123 -a <<EOF
dn: uid=tuser2,ou=people,o=my.com
objectclass: top
objectclass: posixAccount
objectclass: person
objectclass: inetorgperson
cn: tuser2
uid: tuser2
sn: tuser2
homeDirectory: /home/tuser2
gidNumber: 2
EOF

adding new entry "uid=tuser2,ou=people,o=my.com"
[jrusnack@dstet ~]$ ldapsearch -h localhost -p 22222 -D "cn=directory manager " -w Secret123 -LLL -b "uid=tuser2,ou=people,o=my.com"
dn: uid=tuser2,ou=People,o=my.com
objectClass: top
objectClass: posixAccount
objectClass: person
objectClass: inetorgperson
objectClass: organizationalPerson
cn: tuser2
uid: tuser2
sn: tuser2
homeDirectory: /home/tuser2
gidNumber: 2
uidNumber: 2

[jrusnack@dstet ~]$ rpm -qa 389*
389-ds-base-1.2.11.15-11.el6.x86_64
389-ds-base-libs-1.2.11.15-11.el6.x86_64


Verified.

Comment 6 errata-xmlrpc 2013-02-21 08:21:26 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.

http://rhn.redhat.com/errata/RHSA-2013-0503.html