* [PATCH] APPARMOR: Fix memory leak of apparmor_init()
@ 2010-11-10 8:05 wzt.wzt
2010-11-10 16:56 ` John Johansen
0 siblings, 1 reply; 2+ messages in thread
From: wzt.wzt @ 2010-11-10 8:05 UTC (permalink / raw)
To: linux-kernel; +Cc: john.johansen, apparmor, linux-security-module
set_init_cxt() allocted sizeof(struct aa_task_cxt) bytes for cxt,
if register_security() failed, it will cause memory leak.
Signed-off-by: Zhitong Wang <zhitong.wangzt@alibaba-inc.com>
---
security/apparmor/lsm.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
index cf1de44..b7106f1 100644
--- a/security/apparmor/lsm.c
+++ b/security/apparmor/lsm.c
@@ -922,7 +922,7 @@ static int __init apparmor_init(void)
error = register_security(&apparmor_ops);
if (error) {
AA_ERROR("Unable to register AppArmor\n");
- goto register_security_out;
+ goto set_init_cxt_out;
}
/* Report that AppArmor successfully initialized */
@@ -936,6 +936,9 @@ static int __init apparmor_init(void)
return error;
+set_init_cxt_out:
+ aa_free_task_context(current->real_cred->security);
+
register_security_out:
aa_free_root_ns();
@@ -944,7 +947,6 @@ alloc_out:
apparmor_enabled = 0;
return error;
-
}
security_initcall(apparmor_init);
--
1.6.5.3
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] APPARMOR: Fix memory leak of apparmor_init()
2010-11-10 8:05 [PATCH] APPARMOR: Fix memory leak of apparmor_init() wzt.wzt
@ 2010-11-10 16:56 ` John Johansen
0 siblings, 0 replies; 2+ messages in thread
From: John Johansen @ 2010-11-10 16:56 UTC (permalink / raw)
To: wzt.wzt; +Cc: linux-kernel, apparmor, linux-security-module
On 11/10/2010 12:05 AM, wzt.wzt@gmail.com wrote:
> set_init_cxt() allocted sizeof(struct aa_task_cxt) bytes for cxt,
> if register_security() failed, it will cause memory leak.
>
> Signed-off-by: Zhitong Wang <zhitong.wangzt@alibaba-inc.com>
>
yep, thanks again Zhitong
Signed-off-by: John Johansen <john.johansen@canonical.com>
> ---
> security/apparmor/lsm.c | 6 ++++--
> 1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
> index cf1de44..b7106f1 100644
> --- a/security/apparmor/lsm.c
> +++ b/security/apparmor/lsm.c
> @@ -922,7 +922,7 @@ static int __init apparmor_init(void)
> error = register_security(&apparmor_ops);
> if (error) {
> AA_ERROR("Unable to register AppArmor\n");
> - goto register_security_out;
> + goto set_init_cxt_out;
> }
>
> /* Report that AppArmor successfully initialized */
> @@ -936,6 +936,9 @@ static int __init apparmor_init(void)
>
> return error;
>
> +set_init_cxt_out:
> + aa_free_task_context(current->real_cred->security);
> +
> register_security_out:
> aa_free_root_ns();
>
> @@ -944,7 +947,6 @@ alloc_out:
>
> apparmor_enabled = 0;
> return error;
> -
> }
>
> security_initcall(apparmor_init);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-11-10 16:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-10 8:05 [PATCH] APPARMOR: Fix memory leak of apparmor_init() wzt.wzt
2010-11-10 16:56 ` John Johansen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox