public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Casey Schaufler <casey@schaufler-ca.com>
To: LSM <linux-security-module@vger.kernel.org>
Cc: Casey Schaufler <casey@schaufler-ca.com>,
	LKLM <linux-kernel@vger.kernel.org>,
	David Howells <dhowells@redhat.com>
Subject: Re: [PATCH] Smack: setprocattr memory leak fix
Date: Thu, 23 Aug 2012 09:51:43 -0700	[thread overview]
Message-ID: <50365F9F.7020308@schaufler-ca.com> (raw)
In-Reply-To: <50352873.9070706@schaufler-ca.com>

On 8/22/2012 11:44 AM, Casey Schaufler wrote:

> From: Casey Schaufler <casey@schaufler-ca.com>
> Subject: [PATCH] Smack: setprocattr memory leak fix
>
> The data structure allocations being done in prepare_creds
> are duplicated in smack_setprocattr. This results in the
> structure allocated in prepare_creds being orphaned and
> never freed. The duplicate code is removed from
> smack_setprocattr.
>
> Targeted for git://git.gitorious.org/smack-next/kernel.git
>
> Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>

Applied to git://git.gitorious.org/smack-next/kernel.git

 

>
> ---
>
>  security/smack/smack_lsm.c |   14 ++------------
>  1 files changed, 2 insertions(+), 12 deletions(-)
>
> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
> index ce9273a..2874c73 100644
> --- a/security/smack/smack_lsm.c
> +++ b/security/smack/smack_lsm.c
> @@ -2684,9 +2684,7 @@ static int smack_getprocattr(struct task_struct *p, char *name, char **value)
>  static int smack_setprocattr(struct task_struct *p, char *name,
>  			     void *value, size_t size)
>  {
> -	int rc;
>  	struct task_smack *tsp;
> -	struct task_smack *oldtsp;
>  	struct cred *new;
>  	char *newsmack;
>  
> @@ -2716,21 +2714,13 @@ static int smack_setprocattr(struct task_struct *p, char *name,
>  	if (newsmack == smack_known_web.smk_known)
>  		return -EPERM;
>  
> -	oldtsp = p->cred->security;
>  	new = prepare_creds();
>  	if (new == NULL)
>  		return -ENOMEM;
>  
> -	tsp = new_task_smack(newsmack, oldtsp->smk_forked, GFP_KERNEL);
> -	if (tsp == NULL) {
> -		kfree(new);
> -		return -ENOMEM;
> -	}
> -	rc = smk_copy_rules(&tsp->smk_rules, &oldtsp->smk_rules, GFP_KERNEL);
> -	if (rc != 0)
> -		return rc;
> +	tsp = new->security;
> +	tsp->smk_task = newsmack;
>  
> -	new->security = tsp;
>  	commit_creds(new);
>  	return size;
>  }
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

  parent reply	other threads:[~2012-08-23 16:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-22 18:44 [PATCH] Smack: setprocattr memory leak fix Casey Schaufler
2012-08-23 12:48 ` David Howells
2012-08-23 15:58   ` Casey Schaufler
2012-08-23 16:51 ` Casey Schaufler [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-08-22 21:49 Casey Schaufler

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=50365F9F.7020308@schaufler-ca.com \
    --to=casey@schaufler-ca.com \
    --cc=dhowells@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    /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