Nfs-utils memory leak Description of problem: Memory leak was found in mountd. I have spotted the leaking point in the source code and a patch to fix is attached bellow. The memory leak does not become critical in normal uses, but in our system we are mounting nearly 100 loopback devices and running 24 hours then the system required to reboot periodically to free up memory consumed by mountd. Version-Release number of selected component (if applicable): nfs-utils-1.0.6-65.EL4.x86_64.rpm Additional info: diff -urN nfs-utils-1.0.6.org/support/export/client.c nfs-utils- 1.0.6.new/support/export/client.c --- nfs-utils-1.0.6.org/support/export/client.c 2007-01-18 15:03:54.000000000 +0900 +++ nfs-utils-1.0.6.new/support/export/client.c 2007-01-18 15:17:53.000000000 +0900 @@ -257,6 +257,10 @@ name = add_name(name, clp->m_hostname); } } + + if (he != NULL) + free(he); + return name; } diff -urN nfs-utils-1.0.6.org/support/misc/mountpoint.c nfs-utils- 1.0.6.new/support/misc/mountpoint.c --- nfs-utils-1.0.6.org/support/misc/mountpoint.c 2003-05-30 13:42:21.000000000 +0900 +++ nfs-utils-1.0.6.new/support/misc/mountpoint.c 2007-01-18 15:06:13.000000000 +0900 @@ -24,8 +24,11 @@ dotdot = malloc(strlen(path)+4); strcat(strcpy(dotdot, path), "/.."); if (lstat(path, &stb) != 0 || - lstat(dotdot, &pstb) != 0) + lstat(dotdot, &pstb) != 0) { + free(dotdot); return 0; + } + free(dotdot); if (stb.st_dev != pstb.st_dev || stb.st_ino == pstb.st_ino)
Created attachment 154383 [details] patch to fix memory leak in nfs-utils
This request was evaluated by Red Hat Product Management for inclusion in a Red Hat Enterprise Linux maintenance release. Product Management has requested further review of this request by Red Hat Engineering, for potential inclusion in a Red Hat Enterprise Linux Update release for currently deployed products. This request is not yet committed for inclusion in an Update release.
Fixed in nfs-utils-1.0.9-18
Same memory leak exist in nfs-utils packages for Red Hat Enterprize Linux 4.5. Please apply for RHEL4 too.
Thanks for the info... I just cloned this bug into a RHEL4.5 one... See: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=239783
I as well had no luck reproducing this leak. but looking at the patch: --- a/support/export/client.c +++ b/support/export/client.c @@ -262,6 +262,10 @@ client_compose(struct in_addr addr) name = add_name(name, clp->m_hostname); } } + + if (he != NULL) + free(he); + return name; } it is very apparent we were not free memory in a routine call client_compose() which is used by rpc.mountd to authenticate incoming ip address.
This request was previously evaluated by Red Hat Product Management for inclusion in the current Red Hat Enterprise Linux release, but Red Hat was unable to resolve it in time. This request will be reviewed for a future Red Hat Enterprise Linux release.
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-2007-0651.html