mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stephen Smalley <sds@tycho.nsa.gov>
To: James Morris <jmorris@namei.org>
Cc: iceberg <strakh@ispras.ru>,
	linux-kernel@vger.kernel.org, selinux@tycho.nsa.gov,
	Eric Paris <eparis@redhat.com>
Subject: Re: [PATCH] SELinux: re. BUG memory leakage at ./security/selinux/hooks.c
Date: Mon, 10 Aug 2009 08:24:07 -0400	[thread overview]
Message-ID: <1249907047.2422.31.camel@moss-pluto.epoch.ncsc.mil> (raw)
In-Reply-To: <alpine.LRH.2.00.0908102216430.10792@tundra.namei.org>

On Mon, 2009-08-10 at 22:17 +1000, James Morris wrote:
> Please review.
> 
> Author: James Morris <jmorris@namei.org>
> Date:   Mon Aug 10 22:00:13 2009 +1000
> 
>     SELinux: fix memory leakage in /security/selinux/hooks.c
>     
>     Fix memory leakage in /security/selinux/hooks.c
>     
>     The buffer always needs to be freed here; we either error
>     out or allocate more memory.
>     
>     Reported-by: iceberg <strakh@ispras.ru>
>     Signed-off-by: James Morris <jmorris@namei.org>

Acked-by:  Stephen Smalley <sds@tycho.nsa.gov>

> 
> diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
> index 15c2a08..1e8cfc4 100644
> --- a/security/selinux/hooks.c
> +++ b/security/selinux/hooks.c
> @@ -1285,6 +1285,8 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
>  		rc = inode->i_op->getxattr(dentry, XATTR_NAME_SELINUX,
>  					   context, len);
>  		if (rc == -ERANGE) {
> +			kfree(context);
> +
>  			/* Need a larger buffer.  Query for the right size. */
>  			rc = inode->i_op->getxattr(dentry, XATTR_NAME_SELINUX,
>  						   NULL, 0);
> @@ -1292,7 +1294,6 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
>  				dput(dentry);
>  				goto out_unlock;
>  			}
> -			kfree(context);
>  			len = rc;
>  			context = kmalloc(len+1, GFP_NOFS);
>  			if (!context) {
> 
-- 
Stephen Smalley
National Security Agency


      reply	other threads:[~2009-08-10 12:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-10  8:57 iceberg
2009-08-10 11:53 ` James Morris
2009-08-10 12:17   ` [PATCH] SELinux: re. " James Morris
2009-08-10 12:24     ` Stephen Smalley [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1249907047.2422.31.camel@moss-pluto.epoch.ncsc.mil \
    --to=sds@tycho.nsa.gov \
    --cc=eparis@redhat.com \
    --cc=jmorris@namei.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=selinux@tycho.nsa.gov \
    --cc=strakh@ispras.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®