Bug 173525 - pam test exhibits memory growth
pam test exhibits memory growth
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: libselinux (Show other bugs)
4.0
i386 Linux
medium Severity high
: ---
: ---
Assigned To: Daniel Walsh
:
Depends On:
Blocks: 181409
  Show dependency treegraph
 
Reported: 2005-11-17 16:58 EST by Warren Otsuka
Modified: 2007-11-30 17:07 EST (History)
5 users (show)

See Also:
Fixed In Version: RHBA-2006-0371
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-08-10 17:15:42 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
PAM test program - cimservera.cpp (5.12 KB, text/plain)
2005-11-17 16:59 EST, Warren Otsuka
no flags Details
PAM test program - cimservera.h (2.71 KB, text/plain)
2005-11-17 17:00 EST, Warren Otsuka
no flags Details
/etc/pam.d/wbem - PAM configuration file for test (478 bytes, text/plain)
2005-11-17 17:02 EST, Warren Otsuka
no flags Details
valdrind output (6.47 KB, text/plain)
2006-02-09 10:01 EST, Chris Williams
no flags Details
test program exhibiting memory growth in libselinux (2.63 KB, text/plain)
2006-04-17 12:27 EDT, Jason Vas Dias
no flags Details
valgrind log from 1 iteration for 1 successful authentication (2.29 KB, text/plain)
2006-04-17 12:34 EDT, Jason Vas Dias
no flags Details
patch to libselinux-1.19.1-7.1 that fixes memory leak in selinux_config.c (1.42 KB, patch)
2006-04-17 12:36 EDT, Jason Vas Dias
no flags Details | Diff
valgrind log from same pam_mem run after libselinux patch applied, showing no memory leak (708 bytes, text/plain)
2006-04-17 12:38 EDT, Jason Vas Dias
no flags Details
valgrind log file showing memory leaks still present with libselinux-1.19-7.1 (1.81 KB, text/plain)
2006-04-28 15:56 EDT, Jason Vas Dias
no flags Details

  None (edit)
Description Warren Otsuka 2005-11-17 16:58:19 EST
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 16:59:46 EST
Created attachment 121207 [details]
PAM test program - cimservera.cpp
Comment 2 Warren Otsuka 2005-11-17 17:00:51 EST
Created attachment 121208 [details]
PAM test program - cimservera.h
Comment 3 Warren Otsuka 2005-11-17 17:02:08 EST
Created attachment 121209 [details]
/etc/pam.d/wbem - PAM configuration file for test
Comment 4 Warren Otsuka 2005-11-21 14:47:22 EST
The memory growth is more pronounced on x86_64 running in 64-bit mode.
Comment 5 Tomas Mraz 2005-11-21 15:17:42 EST
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 10:01:41 EST
Created attachment 124437 [details]
valdrind output
Comment 9 Tomas Mraz 2006-02-09 11:39:20 EST
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 15:46:23 EST
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 16:55:01 EST
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 09:39:28 EST
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 14:39:38 EDT
Which process is growing out of control?
Comment 19 Daniel Walsh 2006-04-11 14:40:47 EDT
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 12:24:22 EDT
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 12:27:38 EDT
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 12:34:00 EDT
Created attachment 127809 [details]
valgrind log from 1 iteration for 1 successful authentication
Comment 23 Jason Vas Dias 2006-04-17 12:36:56 EDT
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 12:38:32 EDT
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 12:42:49 EDT
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 15:54:01 EDT
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 15:56:50 EDT
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 17:28:38 EDT
added patch libselinux-1_19_1-7_2
Comment 34 Jason Vas Dias 2006-04-28 17:45:16 EDT
Terrific! Thanks alot, Dan - all tests pass now - no memory leaks observed.

Comment 41 Red Hat Bugzilla 2006-08-10 17:15:43 EDT
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

Note You need to log in before you can comment on or make changes to this bug.