diff options
author | Casey Schaufler <casey@schaufler-ca.com> | 2012-08-22 14:44:03 -0400 |
---|---|---|
committer | Casey Schaufler <casey@schaufler-ca.com> | 2012-09-18 12:51:06 -0400 |
commit | 46a2f3b9e99353cc63e15563e8abee71162330f7 (patch) | |
tree | 0d8857d5209990480975cc76379f6de1b4c0bf24 /security | |
parent | 449543b0436a9146b855aad39eab76ae4853e88d (diff) |
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>
Diffstat (limited to 'security')
-rw-r--r-- | 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 ce9273a18165..2874c7316783 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) | |||
2684 | static int smack_setprocattr(struct task_struct *p, char *name, | 2684 | static int smack_setprocattr(struct task_struct *p, char *name, |
2685 | void *value, size_t size) | 2685 | void *value, size_t size) |
2686 | { | 2686 | { |
2687 | int rc; | ||
2688 | struct task_smack *tsp; | 2687 | struct task_smack *tsp; |
2689 | struct task_smack *oldtsp; | ||
2690 | struct cred *new; | 2688 | struct cred *new; |
2691 | char *newsmack; | 2689 | char *newsmack; |
2692 | 2690 | ||
@@ -2716,21 +2714,13 @@ static int smack_setprocattr(struct task_struct *p, char *name, | |||
2716 | if (newsmack == smack_known_web.smk_known) | 2714 | if (newsmack == smack_known_web.smk_known) |
2717 | return -EPERM; | 2715 | return -EPERM; |
2718 | 2716 | ||
2719 | oldtsp = p->cred->security; | ||
2720 | new = prepare_creds(); | 2717 | new = prepare_creds(); |
2721 | if (new == NULL) | 2718 | if (new == NULL) |
2722 | return -ENOMEM; | 2719 | return -ENOMEM; |
2723 | 2720 | ||
2724 | tsp = new_task_smack(newsmack, oldtsp->smk_forked, GFP_KERNEL); | 2721 | tsp = new->security; |
2725 | if (tsp == NULL) { | 2722 | tsp->smk_task = newsmack; |
2726 | kfree(new); | ||
2727 | return -ENOMEM; | ||
2728 | } | ||
2729 | rc = smk_copy_rules(&tsp->smk_rules, &oldtsp->smk_rules, GFP_KERNEL); | ||
2730 | if (rc != 0) | ||
2731 | return rc; | ||
2732 | 2723 | ||
2733 | new->security = tsp; | ||
2734 | commit_creds(new); | 2724 | commit_creds(new); |
2735 | return size; | 2725 | return size; |
2736 | } | 2726 | } |