[PATCH] Patch for memory leak in vfs_defaults.c
Jeremy Allison
jra at samba.org
Mon Apr 9 15:42:50 UTC 2018
On Fri, Apr 06, 2018 at 04:03:08PM -0700, Jeremy Allison wrote:
> On Fri, Apr 06, 2018 at 04:40:44PM -0400, Andrew Walker via samba-technical wrote:
> > Hi all,
> > I encountered an issue where several FreeNAS users on samba 4.7 were
> > experiencing memory leak resulting in single smbd process consuming all
> > available RAM and swap space. Disabling the getwd cache significantly
> > increased rate of leak, and enabling widelinks / disabling unix extensions
> > made the leak apparently stop. Investigation indicated that the leak was in
> > vfswrap_getwd().
> >
> > The attached patch resolved the issue.
>
> OK, here is the version I'd like to push. Confirmed fixed by
> the submitter.
>
> Ralph, can you do a quick review ?
Ping ! Anyone on the Team, can I get a +1 here please ?
It's a really bad memory leak on potentially (depending
on directory cache settings) a hot code path, and I'd
really like to get it fixed in master and 4.8.next, 4.7.next
(the only releases it's a problem).
Plus as the original bug was my fault, it's making me feel
really bad :-).
Thanks !
Jeremy.
> From 92e8095023f82238c0490fc36a38af0ba9eeed8c Mon Sep 17 00:00:00 2001
> From: Jeremy Allison <jra at samba.org>
> Date: Fri, 6 Apr 2018 13:52:52 -0700
> Subject: [PATCH] s3: smbd: Fix memory leak in vfswrap_getwd()
>
> BUG: https://bugzilla.samba.org/show_bug.cgi?id=13372
>
> Signed-off-by: Andrew Walker <awalker at ixsystems.com>.
> Reviewed-by: Jeremy Allison <jra at samba.org>
> ---
> source3/modules/vfs_default.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
> index a26bec457ae..a9c87e444fe 100644
> --- a/source3/modules/vfs_default.c
> +++ b/source3/modules/vfs_default.c
> @@ -2229,9 +2229,12 @@ static struct smb_filename *vfswrap_getwd(vfs_handle_struct *handle,
> NULL,
> NULL,
> 0);
> - if (smb_fname == NULL) {
> - SAFE_FREE(result);
> - }
> + /*
> + * sys_getwd() *always* returns malloced memory.
> + * We must free here to avoid leaks:
> + * BUG:https://bugzilla.samba.org/show_bug.cgi?id=13372
> + */
> + SAFE_FREE(result);
> return smb_fname;
> }
>
> --
> 2.17.0.484.g0c8726318c-goog
>
More information about the samba-technical
mailing list