Skip to contentSkip to conversation

Apparent memory leak in libselinux

DISCUSSION Stephen Smalley 2 participants 2 messages Jan 4, 2010 – Mar 6, 2010 2 messages not in the archive SELinux security module

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 9 lines · Ed Swierk

When I run the following on a F12 system booted with selinux=0, the tcmalloc heap checker complains about a leak somewhere in libselinux:

$ HEAPCHECK=normal LD_PRELOAD=/usr/lib64/libtcmalloc.so.0
/usr/bin/python -c 'import _ssl'

Leak check _main_ detected leaks of 120 bytes in 1 objects The 1 largest leaks:
Leak of 120 bytes in 1 objects allocated from:

Quoted 8 lines
       @ 0x3bf9866589 _IO_getdelim
       @ 0x3bfb40ca53 set_selinuxmnt
       @ 0x3bfb414fe6 string_to_security_class
       @ 0x3bfb404cdb _init
       @ 0x7fff4bdfa8ed 0x00007fff4bdfa8ed

No leak is detected when I run this with selinux enabled. My system has libselinux-2.0.87-1.fc12 installed.

Likely introduced by Eric's short cut for checking /proc/filesystems and bailing immediately in the non-selinux case. Try this:

libselinux/src/init.c +3 -1
index ecb3199..4d010dc 100644
@@ -59,8 +59,10 @@ static void init_selinuxmnt(void)
 	}
 	fclose(fp);
 
-	if (!exists)
+	if (!exists) {
+		free(buf);
 		return;
+	}
 
 	/* At this point, the usual spot doesn't have an selinuxfs so
 	 * we look around for it */
Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 7 lines · Ed Swierk
Quoted 2 lines · Stephen Smalley

Likely introduced by Eric's short cut for checking /proc/filesystems and bailing immediately in the non-selinux case. Try this:

There are a couple of other leakage cases to worry about. I submitted a patch here: http://userspace.selinuxproject.org/trac/ticket/10

Can you send the patch to the list please?

Guidelines on patch preparations are available at:
http://userspace.selinuxproject.org/trac/wiki/Contributing

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.