lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100106172541.GB15784@us.ibm.com>
Date:	Wed, 6 Jan 2010 11:25:41 -0600
From:	"Serge E. Hallyn" <serue@...ibm.com>
To:	Jiri Slaby <jslaby@...e.cz>
Cc:	jmorris@...ei.org, linux-security-module@...r.kernel.org,
	linux-kernel@...r.kernel.org, jirislaby@...il.com,
	David Howells <dhowells@...hat.com>
Subject: Re: [PATCH 1/1] cred: fix memory leak

Quoting Jiri Slaby (jslaby@...e.cz):
> Stanse found a memory leak in prepare_exec_creds. tgcred is not
> freed/assigned on all paths. Fix that.
> 
> I.e. unifdef tgcred and add kfree(tgcred); as it is initialized to
> NULL already.

Does this compile with CONFIG_KEYS=n, , though?  I don't see a dummy
define for struct thread_group_cred in cred.h.  Should this patch add
one?

> Signed-off-by: Jiri Slaby <jslaby@...e.cz>
> Cc: David Howells <dhowells@...hat.com>
> Cc: James Morris <jmorris@...ei.org>
> Cc: Serge Hallyn <serue@...ibm.com>
> ---
>  kernel/cred.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/cred.c b/kernel/cred.c
> index dd76cfe..0e10f73 100644
> --- a/kernel/cred.c
> +++ b/kernel/cred.c
> @@ -351,9 +351,7 @@ struct cred *prepare_exec_creds(void)
>   */
>  struct cred *prepare_usermodehelper_creds(void)
>  {
> -#ifdef CONFIG_KEYS
>  	struct thread_group_cred *tgcred = NULL;
> -#endif
>  	struct cred *new;
> 
>  #ifdef CONFIG_KEYS
> @@ -363,8 +361,10 @@ struct cred *prepare_usermodehelper_creds(void)
>  #endif
> 
>  	new = kmem_cache_alloc(cred_jar, GFP_ATOMIC);
> -	if (!new)
> +	if (!new) {
> +		kfree(tgcred);
>  		return NULL;
> +	}
> 
>  	kdebug("prepare_usermodehelper_creds() alloc %p", new);
> 
> -- 
> 1.6.5.7
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ