Commit 46a2f3b9 authored by Casey Schaufler's avatar Casey Schaufler

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.gitSigned-off-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
parent 449543b0
...@@ -2684,9 +2684,7 @@ static int smack_getprocattr(struct task_struct *p, char *name, char **value) ...@@ -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, static int smack_setprocattr(struct task_struct *p, char *name,
void *value, size_t size) void *value, size_t size)
{ {
int rc;
struct task_smack *tsp; struct task_smack *tsp;
struct task_smack *oldtsp;
struct cred *new; struct cred *new;
char *newsmack; char *newsmack;
...@@ -2716,21 +2714,13 @@ static int smack_setprocattr(struct task_struct *p, char *name, ...@@ -2716,21 +2714,13 @@ static int smack_setprocattr(struct task_struct *p, char *name,
if (newsmack == smack_known_web.smk_known) if (newsmack == smack_known_web.smk_known)
return -EPERM; return -EPERM;
oldtsp = p->cred->security;
new = prepare_creds(); new = prepare_creds();
if (new == NULL) if (new == NULL)
return -ENOMEM; return -ENOMEM;
tsp = new_task_smack(newsmack, oldtsp->smk_forked, GFP_KERNEL); tsp = new->security;
if (tsp == NULL) { tsp->smk_task = newsmack;
kfree(new);
return -ENOMEM;
}
rc = smk_copy_rules(&tsp->smk_rules, &oldtsp->smk_rules, GFP_KERNEL);
if (rc != 0)
return rc;
new->security = tsp;
commit_creds(new); commit_creds(new);
return size; return size;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment