Issue 8759 - mixed overlay nops & memberof cause segfault
Summary: mixed overlay nops & memberof cause segfault
Status: VERIFIED WONTFIX
Alias: None
Product: OpenLDAP
Classification: Unclassified
Component: overlays (show other issues)
Version: 2.4.44
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-20 16:13 UTC by zhixu.liu@gmail.com
Modified: 2021-01-11 17:35 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 zhixu.liu@gmail.com 2017-10-20 16:13:33 UTC
Full_Name: Z. Liu
Version: 2.4.44
OS: Gentoo
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (221.218.169.84)


if we enable overlay nops & memberof together, then doing a member MODDN
operation, slapd will segfault and exit immediately.

Example operation:

dn: uid=test,ou=People,dc=example,dc=dc=com
changetype: moddn
newrdn: uid=chenln
deleteoldrdn: 1
newsuperior: ou=Leave,dc=example,dc=com

The reason is: in servers/slapd/overlays/memberof.c, function
memberof_value_modify define mod/values/nvalues in the stack, which will be
passed to other overlays, nops will try to free them if no attribute is changed.
Comment 1 Z Liu 2017-12-15 09:44:24 UTC
# more /etc/openldap/slapd.conf
include        /etc/openldap/schema/core.schema
include        /etc/openldap/schema/cosine.schema
include        /etc/openldap/schema/inetorgperson.schema
include        /etc/openldap/schema/rfc2307bis.schema

pidfile        /run/openldap/slapd.pid
argsfile       /run/openldap/slapd.args

moduleload     memberof.so
moduleload     nops-overlay.so

database       hdb
suffix         "o=demo,c=cn"
rootdn         "cn=root,o=demo,c=cn"
rootpw         "123456"
directory      /var/lib/openldap-data/

overlay memberof
memberof-group-oc groupOfMembers
memberof-refint   true

overlay nops

# more /tmp/1.ldif
dn: o=demo,c=cn
o: demo
objectClass: organization
structuralObjectClass: organization

dn: ou=Group,o=demo,c=cn
objectClass: organizationalUnit
ou: Group

dn: ou=People,o=demo,c=cn
objectClass: organizationalUnit
ou: People

dn: ou=Leave,o=demo,c=cn
objectClass: organizationalUnit
ou: Leave

dn: uid=liuzx,ou=People,o=demo,c=cn
gidNumber: 20000
objectClass: posixAccount
objectClass: inetOrgPerson
structuralObjectClass: inetOrgPerson
uidNumber: 10000
uid: liuzx
homeDirectory: /home/users/liuzx
sn: Liu
cn: Z. Liu
memberOf: cn=users,ou=Group,o=demo,c=cn
mobile: 13910823475

dn: cn=users,ou=Group,o=demo,c=cn
objectClass: groupOfMembers
cn: users
member: uid=liuzx,ou=People,o=demo,c=cn

# sudo -u ldap slapadd -l 1.ldif
# service slapd start
# ps | grep slapd # confirm slapd is running
# more ~/t.ldif
dn: uid=liuzx,ou=People,o=demo,c=cn
changetype: moddn
newrdn: uid=liuzx
deleteoldrdn: 1
newsuperior: ou=Leave,o=demo,c=cn

# ldapmodify -H ldap://127.0.0.1 -D 'cn=root,o=demo,c=cn' -w 123456  -f t.ldif
modifying rdn of entry "uid=liuzx,ou=People,o=demo,c=cn"
ldap_result: Can't contact LDAP server (-1)

# ps | grep slapd # confirm slapd is gone

sometimes dmesg can see kernel log:
traps: slapd[25560] general protection ip:7fabf60b0e72 sp:7fabd969bfd0 error:0 in libc-2.23.so[7fabf6068000+19f000]
slapd[26437]: segfault at 737265626d81 ip 00000000004aa4d0 sp 00007f63c2c79710 error 4 in slapd[400000+15a000]
Comment 2 Howard Chu 2018-07-06 20:07:24 UTC
zhixu.liu@gmail.com wrote:
> Full_Name: Z. Liu
> Version: 2.4.44
> OS: Gentoo
> URL: ftp://ftp.openldap.org/incoming/
> Submission from: (NULL) (221.218.169.84)
> 
> 
> if we enable overlay nops & memberof together, then doing a member MODDN
> operation, slapd will segfault and exit immediately.
> 
> Example operation:
> 
> dn: uid=test,ou=People,dc=example,dc=dc=com
> changetype: moddn
> newrdn: uid=chenln
> deleteoldrdn: 1
> newsuperior: ou=Leave,dc=example,dc=com
> 
> The reason is: in servers/slapd/overlays/memberof.c, function
> memberof_value_modify define mod/values/nvalues in the stack, which will be
> passed to other overlays, nops will try to free them if no attribute is changed.

Note that code in contrib is unsupported and is not actually part of OpenLDAP 
Software. You can either contact the nops author and ask them for a fix, or 
you're welcome to submit a fix yourself. Nobody in the OpenLDAP Project is 
going to investigate this issue.

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