Patch for memory leak in vfs_defaults.c

Jeremy Allison jra at samba.org
Fri Apr 6 20:58:29 UTC 2018


On Fri, Apr 06, 2018 at 01:55:38PM -0700, Jeremy Allison via samba-technical 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.
> 
> Oh god that's *embarassing*. Looks like my fault too, sorry.
> 
> Thanks very much for finding that.
> 
> Can you try the attached patch instead and confirm it fixes it,
> it's a smaller and simpler change.


Andrew, can you add yourself as a user in bugzilla.samba.org,
I've logged this as bug:

https://bugzilla.samba.org/show_bug.cgi?id=13372

and I'd like to add you to the bug report.


> From f86417b5ec41c4260c3a706811c2a3c075b9402d 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()
> 
> Based on a patch from Andrew Walker <awalker at ixsystems.com>.
> 
> Signed-off-by: Jeremy Allison <jra at samba.org>
> ---
>  source3/modules/vfs_default.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
> index a26bec457ae..cf69f7a060e 100644
> --- a/source3/modules/vfs_default.c
> +++ b/source3/modules/vfs_default.c
> @@ -2229,9 +2229,7 @@ static struct smb_filename *vfswrap_getwd(vfs_handle_struct *handle,
>  				NULL,
>  				NULL,
>  				0);
> -	if (smb_fname == NULL) {
> -		SAFE_FREE(result);
> -	}
> +	SAFE_FREE(result);
>  	return smb_fname;
>  }
>  
> -- 
> 2.17.0.484.g0c8726318c-goog
> 




More information about the samba-technical mailing list