Memory leak in authunix_create_default()...

Andrew Boyer aboyer at averesystems.com
Mon Apr 23 17:48:56 UTC 2012


On Apr 23, 2012, at 1:44 PM, Dimitry Andric wrote:

> On 2012-04-23 19:31, Andrew Boyer wrote:
>> Begin forwarded message:
>> 
>>> From: Greg Bednarek <gbednarek at averesystems.com>
>>> Date: April 16, 2012 10:54:33 AM EDT
>>> To: freebsd-current at freebsd.org
>>> Cc: Andrew Boyer <aboyer at averesystems.com>
>>> Subject: Memory leak in authunix_create_default()...
>>> 
>>> 
>>> Please see the attached patch for a proposed fix for a memory leak in authunix_create_default().
>>> 
>>> The leak appears to have been introduced 6/19/2009 in Revision 194494 of lib/libc/rpc/auth_unix.c
>>> 
>>> As you can see form the patch, the fix is very simple. The issue was discovered when tracking down some rather drastic increases in application memory footprint during certain types of workloads, and was eventually traced it to this (apparently) not very heavily used path in libc.
>>> 
>>> I would appreciate hearing any comments/concerns with the proposed fix.
> 
> Hi,
> 
> The patch itself seems to have gone missing?


Trying again...

-------------- next part --------------
A non-text attachment was scrubbed...
Name: auth_unix.diff
Type: application/octet-stream
Size: 665 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20120423/68c67924/auth_unix.obj
-------------- next part --------------


Index: lib/libc/rpc/auth_unix.c
===================================================================
--- lib/libc/rpc/auth_unix.c	(revision 234224)
+++ lib/libc/rpc/auth_unix.c	(working copy)
@@ -185,6 +185,7 @@
 AUTH *
 authunix_create_default()
 {
+	AUTH *auth;
 	int ngids;
 	long ngids_max;
 	char machname[MAXHOSTNAMELEN + 1];
@@ -207,8 +208,10 @@
 	if (ngids > NGRPS)
 		ngids = NGRPS;
 	/* XXX: interface problem; those should all have been unsigned */
-	return (authunix_create(machname, (int)uid, (int)gid, ngids,
-	    (int *)gids));
+	auth = authunix_create(machname, (int)uid, (int)gid, ngids,
+	    (int *)gids);
+	free(gids);
+	return (auth);
 }
 
 /*



--------------------------------------------------
Andrew Boyer	aboyer at averesystems.com






More information about the freebsd-current mailing list