* [PATCH] APPARMOR: Fix memory leak of alloc_namespace()
@ 2010-11-10 3:31 wzt.wzt
2010-11-10 16:51 ` John Johansen
0 siblings, 1 reply; 2+ messages in thread
From: wzt.wzt @ 2010-11-10 3:31 UTC (permalink / raw)
To: linux-kernel; +Cc: john.johansen, apparmor, linux-security-module
policy->name is a substring of policy->hname, if prefix is not NULL, it will
allocted strlen(prefix) + strlen(name) + 3 bytes to policy->hname in policy_init().
use kzfree(ns->base.name) will casue memory leak if alloc_namespace() failed.
Signed-off-by: Zhitong Wang <zhitong.wangzt@alibaba-inc.com>
---
security/apparmor/policy.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/security/apparmor/policy.c b/security/apparmor/policy.c
index 52cc865..4f0eade 100644
--- a/security/apparmor/policy.c
+++ b/security/apparmor/policy.c
@@ -306,7 +306,7 @@ static struct aa_namespace *alloc_namespace(const char *prefix,
return ns;
fail_unconfined:
- kzfree(ns->base.name);
+ kzfree(ns->base.hname);
fail_ns:
kzfree(ns);
return NULL;
--
1.6.5.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] APPARMOR: Fix memory leak of alloc_namespace()
2010-11-10 3:31 [PATCH] APPARMOR: Fix memory leak of alloc_namespace() wzt.wzt
@ 2010-11-10 16:51 ` John Johansen
0 siblings, 0 replies; 2+ messages in thread
From: John Johansen @ 2010-11-10 16:51 UTC (permalink / raw)
To: wzt.wzt; +Cc: linux-kernel, apparmor, linux-security-module
On 11/09/2010 07:31 PM, wzt.wzt@gmail.com wrote:
> policy->name is a substring of policy->hname, if prefix is not NULL, it will
> allocted strlen(prefix) + strlen(name) + 3 bytes to policy->hname in policy_init().
> use kzfree(ns->base.name) will casue memory leak if alloc_namespace() failed.
>
> Signed-off-by: Zhitong Wang <zhitong.wangzt@alibaba-inc.com>
yes, thank you.
Signed-off-by: John Johansen <john.johansen@canonical.com>
>
> ---
> security/apparmor/policy.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/security/apparmor/policy.c b/security/apparmor/policy.c
> index 52cc865..4f0eade 100644
> --- a/security/apparmor/policy.c
> +++ b/security/apparmor/policy.c
> @@ -306,7 +306,7 @@ static struct aa_namespace *alloc_namespace(const char *prefix,
> return ns;
>
> fail_unconfined:
> - kzfree(ns->base.name);
> + kzfree(ns->base.hname);
> fail_ns:
> kzfree(ns);
> return NULL;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-11-10 16:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-10 3:31 [PATCH] APPARMOR: Fix memory leak of alloc_namespace() wzt.wzt
2010-11-10 16:51 ` John Johansen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox