Bug 173525

Summary: pam test exhibits memory growth
Product: Red Hat Enterprise Linux 4 Reporter: Warren Otsuka <warren.otsuka>
Component: libselinuxAssignee: Daniel Walsh <dwalsh>
Status: CLOSED ERRATA QA Contact:
Severity: high Docs Contact:
Priority: medium    
Version: 4.0CC: jvdias, pgraner, sgrubb, tao, tmraz
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: RHBA-2006-0371 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-08-10 21:15:42 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: 181409    
Attachments:
Description Flags
PAM test program - cimservera.cpp
none
PAM test program - cimservera.h
none
/etc/pam.d/wbem - PAM configuration file for test
none
valdrind output
none
test program exhibiting memory growth in libselinux
none
valgrind log from 1 iteration for 1 successful authentication
none
patch to libselinux-1.19.1-7.1 that fixes memory leak in selinux_config.c
none
valgrind log from same pam_mem run after libselinux patch applied, showing no memory leak
none
valgrind log file showing memory leaks still present with libselinux-1.19-7.1 none

Description Warren Otsuka 2005-11-17 21:58:19 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7

Description of problem:
Running a standalone program generating pam calls shows memory growth. 

Version-Release number of selected component (if applicable):
pam-0.77-66.5

How reproducible:
Always

Steps to Reproduce:
1. Compile and run the attached cimservera.cpp file.
2.
3.
  

Actual Results:  The program has an infinite loop and top shows the process growing.

Additional info:

Comment 1 Warren Otsuka 2005-11-17 21:59:46 UTC
Created attachment 121207 [details]
PAM test program - cimservera.cpp

Comment 2 Warren Otsuka 2005-11-17 22:00:51 UTC
Created attachment 121208 [details]
PAM test program - cimservera.h

Comment 3 Warren Otsuka 2005-11-17 22:02:08 UTC
Created attachment 121209 [details]
/etc/pam.d/wbem - PAM configuration file for test

Comment 4 Warren Otsuka 2005-11-21 19:47:22 UTC
The memory growth is more pronounced on x86_64 running in 64-bit mode.

Comment 5 Tomas Mraz 2005-11-21 20:17:42 UTC
Please report the bug using the issue tracker. This way it can get proper
attention for fixing in RHEL 4. Also mention this bug report number in the issue
tracker entry. Thank you.


Comment 8 Chris Williams 2006-02-09 15:01:41 UTC
Created attachment 124437 [details]
valdrind output

Comment 9 Tomas Mraz 2006-02-09 16:39:20 UTC
I've tried to reproduce it and I couldn't find any memory leaks neither with
valgrind nor with mtrace().

I've actually already traced for memory leaks in a year ago and there were some
mem-leaks in pam_stack.so but that was it.

So I don't think there are any memory leaks in PAM currently - at least not in
the modules specified in the wbem config file.


Comment 15 Tomas Mraz 2006-03-17 20:46:23 UTC
Thanks for the debugging. I've finally found out what is the culprit. The
problem lies in the selinux library which contains constructor functions
init_selinuxmnt and init_selinux_policyroot which allocate various data and
there are no appropriate destructors.


Comment 16 Daniel Walsh 2006-03-17 21:55:01 UTC
Do we need this fixed, since this only happens when you load the library?  It is
fixed in the upstream version.

This would only leak memory if you were repeatedly doing dlopen and closes on
libselinux.

Comment 17 Tomas Mraz 2006-03-19 14:39:28 UTC
This is exactly what happens when you call PAM repeatedly in one process. So I'd
say this selinux library defect should be fixed.


Comment 18 Daniel Walsh 2006-04-11 18:39:38 UTC
Which process is growing out of control?


Comment 19 Daniel Walsh 2006-04-11 18:40:47 UTC
BTW  1.19.1-7.1 has a fix for this.  But I still do not know if this is worth
updating.

Comment 20 Jason Vas Dias 2006-04-17 16:24:22 UTC
Yes, please can we get a fix for this issue in RHEL-4-U4 - it is causing all
users of the tog-pegasus package a major headache, as the tog-pegausus cimserver
performs PAM authentication for every request, and experiences around 1K memory
growth per request, all due to libselinux memory leaks.
I'm attaching the test program, the valgrind output, and the patch that fixes
the major libselinux memory leak.


Comment 21 Jason Vas Dias 2006-04-17 16:27:38 UTC
Created attachment 127808 [details]
test program exhibiting memory growth in libselinux

Usage:
# gcc -g -o pam_mem pam_mem.c -lpam -lselinux
# valgrind --tool=memcheck --leak-check=yes --show-reachable=yes
--leak-resolution=high --num-callers=40 ./pam_mem pegasus pegasus
(assuming you have a "pegasus" user with password "pegasus")

Comment 22 Jason Vas Dias 2006-04-17 16:34:00 UTC
Created attachment 127809 [details]
valgrind log from 1 iteration for 1 successful authentication

Comment 23 Jason Vas Dias 2006-04-17 16:36:56 UTC
Created attachment 127810 [details]
patch to libselinux-1.19.1-7.1 that fixes memory leak in selinux_config.c

Comment 24 Jason Vas Dias 2006-04-17 16:38:32 UTC
Created attachment 127811 [details]
valgrind log from same pam_mem run after libselinux patch applied, showing no memory leak

Comment 25 Jason Vas Dias 2006-04-17 16:42:49 UTC
Please can we try to get a fix into RHEL-4-U4 for this issue - it is causing
IBM and HP pegasus users major problems, and is the #1 issue they would like
us to fix for pegasus in RHEL-4.

Comment 31 Jason Vas Dias 2006-04-28 19:54:01 UTC
Unfortunately, the updated libselinux-1.19.1-7.1 package submitted for errata 
RHBA-2006:0371-03 still contains the most significant memory leak - it fixes
only the leak of the "selinux_mnt" memory, not the leak of the 
selinux_policyroot memory nor that of the file_paths[i] .  

Please see the patch which fixes those leaks which I attached to this bug
earlier :
  Attachment 127810 [details] https://bugzilla.redhat.com/bugzilla//attachment.cgi?id=127810

The updated libselinux-1.19.1-7.1 packages attached to errata RHBA-2006:0371-03 
generated the memory leaks shown in the 'pam_mem_valgrind-1.19-7.1.log' 
I'm just about to attach .

Comment 32 Jason Vas Dias 2006-04-28 19:56:50 UTC
Created attachment 128371 [details]
valgrind log file showing memory leaks still present with libselinux-1.19-7.1

Comment 33 Daniel Walsh 2006-04-28 21:28:38 UTC
added patch libselinux-1_19_1-7_2

Comment 34 Jason Vas Dias 2006-04-28 21:45:16 UTC
Terrific! Thanks alot, Dan - all tests pass now - no memory leaks observed.



Comment 41 Red Hat Bugzilla 2006-08-10 21:15:43 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2006-0371.html