Re: [PATCH] APPARMOR: Fix memory leak of alloc_namespace()

From: John Johansen
Date: Wed Nov 10 2010 - 11:51:13 EST


On 11/09/2010 07:31 PM, wzt.wzt@xxxxxxxxx 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@xxxxxxxxxxxxxxx>
yes, thank you.

Signed-off-by: John Johansen <john.johansen@xxxxxxxxxxxxx>

>
> ---
> 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;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/