[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <15945270.AQEhGkaEur@sifl>
Date: Mon, 25 Nov 2013 17:02:59 -0500
From: Paul Moore <paul@...l-moore.com>
To: "Geyslan G. Bem" <geyslan@...il.com>
Cc: linux-kernel@...r.kernel.org, Stephen Smalley <sds@...ho.nsa.gov>,
James Morris <james.l.morris@...cle.com>,
Eric Paris <eparis@...isplace.org>,
linux-security-module@...r.kernel.org, selinux@...ho.nsa.gov
Subject: Re: [PATCH] selinux: fix possible memory leak
On Sunday, November 24, 2013 08:37:01 AM Geyslan G. Bem wrote:
> Free 'ctx_str' when necessary.
>
> Signed-off-by: Geyslan G. Bem <geyslan@...il.com>
> ---
> security/selinux/xfrm.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
Nice catch, applied.
> diff --git a/security/selinux/xfrm.c b/security/selinux/xfrm.c
> index a91d205..cf79a45 100644
> --- a/security/selinux/xfrm.c
> +++ b/security/selinux/xfrm.c
> @@ -327,19 +327,22 @@ int selinux_xfrm_state_alloc_acquire(struct xfrm_state
> *x, return rc;
>
> ctx = kmalloc(sizeof(*ctx) + str_len, GFP_ATOMIC);
> - if (!ctx)
> - return -ENOMEM;
> + if (!ctx) {
> + rc = -ENOMEM;
> + goto out;
> + }
>
> ctx->ctx_doi = XFRM_SC_DOI_LSM;
> ctx->ctx_alg = XFRM_SC_ALG_SELINUX;
> ctx->ctx_sid = secid;
> ctx->ctx_len = str_len;
> memcpy(ctx->ctx_str, ctx_str, str_len);
> - kfree(ctx_str);
>
> x->security = ctx;
> atomic_inc(&selinux_xfrm_refcount);
> - return 0;
> +out:
> + kfree(ctx_str);
> + return rc;
> }
>
> /*
--
paul moore
www.paul-moore.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists