Bug 748412

Summary: Memory leaks during the initgroups() operation
Product: Red Hat Enterprise Linux 6 Reporter: Jakub Hrozek <jhrozek>
Component: sssdAssignee: Stephen Gallagher <sgallagh>
Status: CLOSED ERRATA QA Contact: IDM QE LIST <seceng-idm-qe-list>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.2CC: ckannan, ddumas, dpal, grajaiya, jgalipea, jzeleny, kbanerje, prc, shaines
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: sssd-1.5.1-61.el6 Doc Type: Bug Fix
Doc Text:
Cause: SSSD didn't free some temporary memory in LDAP provider. Consequence: When running initgroups() operations, SSSD consumed extensive amount of memory, especially for complex membership structures. Fix: SSSD now frees memory in affected code. Result: SSSD memory consumption is as expected.
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-12-06 16:41:13 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: 750914    

Description Jakub Hrozek 2011-10-24 11:53:26 UTC
Description of problem:
The LDAP provider of SSSD does not correctly release all memory during the initgroups() operation.


Version-Release number of selected component (if applicable):
sssd-1.5.1-60

How reproducible:
always

Steps to Reproduce:
1. configure a RFC2307bis LDAP domain
2. perform logins to trigger initgroups
  
Actual results:
sssd_be leaks memory

Expected results:
no leaks

Additional info:
The initgroups operation is performed as a part of every user login

Comment 1 Jenny Severance 2011-10-25 14:49:21 UTC
Please add steps complete steps to verify/reproduce Thanks

Comment 2 Jakub Hrozek 2011-10-25 16:13:12 UTC
1. configure and start SSSD
2. run "ps axo rss,comm | grep sssd_be" The output shold look something like this:
"4292 sssd_be", the number indicates the size of physical memory the process has allocated.
3. Perform initgroups:
   id -G $username
4. Check memory consumption after each initgroups operation. The number would still go up even with the patch, but with the affected packages, the number would increase much dramatically.

To exercise the affected branches of code, you can perform initgroups on users that are members of nested groups or users that are members of different groups that other users to force adding new groups into the cache on each initgroups operation.

Comment 4 Jan Zeleny 2011-10-27 11:39:52 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause: SSSD didn't free some temporary memory in LDAP provider.
Consequence: When running initgroups() operations, SSSD consumed extensive amount of memory, especially for complex membership structures.
Fix: SSSD now frees memory in affected code.
Result: SSSD memory consumption is as expected.

Comment 5 Kaushik Banerjee 2011-10-31 12:38:50 UTC
Verified in version:
# rpm -qi sssd | head
Name        : sssd                         Relocations: (not relocatable)
Version     : 1.5.1                             Vendor: Red Hat, Inc.
Release     : 63.el6                        Build Date: Wed 26 Oct 2011 09:12:47 PM IST
Install Date: Mon 31 Oct 2011 12:48:24 PM IST      Build Host: x86-002.build.bos.redhat.com
Group       : Applications/System           Source RPM: sssd-1.5.1-63.el6.src.rpm
Size        : 3615338                          License: GPLv3+
Signature   : (none)
Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
URL         : http://fedorahosted.org/sssd/
Summary     : System Security Services Daemon


Verified with valgrind that we no longer see the following leaks:
by 0xB12A09D: save_rfc2307bis_user_memberships (in /usr/lib64/sssd/libsss_ldap.so.1.0.0)


Also, the following comparisons were performed with earlier build:

With 1.5.1-60:

# ps axo rss,comm | grep sssd_be ------> After restarting sssd.
 3512 sssd_be
# ps axo rss,comm | grep sssd_be ------> id user8 (user8 is member of 2 level nested group)
 6324 sssd_be
# ps axo rss,comm | grep sssd_be ------> id user9 (user9 is member of 5 normal groups)
 6332 sssd_be
# ps axo rss,comm | grep sssd_be ------> id user10 (user10 is member of 2 level nested group)
 6336 sssd_be

With 1.5.1-63:

# ps axo rss,comm | grep sssd_be ------> After restarting sssd.
 3512 sssd_be
# ps axo rss,comm | grep sssd_be ------> id user8 (user8 is member of 2 level nested group)
 6180 sssd_be
# ps axo rss,comm | grep sssd_be ------> id user9 (user9 is member of 5 normal groups)
 6176 sssd_be
# ps axo rss,comm | grep sssd_be ------> id user10 (user10 is member of 2 level nested group)
 6184 sssd_be

Comment 6 errata-xmlrpc 2011-12-06 16:41:13 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/RHBA-2011-1529.html