From: Stefan Berger <stefanb@linux.ibm.com>
To: Denis Semakin <denis.semakin@huawei.com>,
linux-integrity@vger.kernel.org
Cc: denis.semakin@huawei-partners.com
Subject: Re: [RFC PATCH v2] ima: fix possible memory leak in cache allocating for namespace
Date: Wed, 28 Dec 2022 11:35:54 -0500 [thread overview]
Message-ID: <67c54e03-fcaa-acfa-2f8b-f14bcab81d68@linux.ibm.com> (raw)
In-Reply-To: <20221226024335.767587-1-denis.semakin@huawei.com>
On 12/25/22 21:43, Denis Semakin wrote:
> There is a KMEM_CACHE(); macro which calls kmem_cache_create() function.
> The default workflow is to call:
> kmem_cache_create();
> kmem_cache_alloc();
> kmem_cache_free();
> kmem_cache_destroy();
>
> But here if register_blocking_lsm_notifier() return an error then
> kmem_cache_destroy() will never calls which can lead a memory leak I suppose.
>
> Signed-off-by: Denis Semakin <denis.semakin@huawei.com>
> Signed-off-by: Ilya Hanov <ilya.hanov@huawei-partners.com>
> ---
> security/integrity/ima/ima_init_ima_ns.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/security/integrity/ima/ima_init_ima_ns.c b/security/integrity/ima/ima_init_ima_ns.c
> index 1eaa6ceee2ee..5c850b740ae6 100644
> --- a/security/integrity/ima/ima_init_ima_ns.c
> +++ b/security/integrity/ima/ima_init_ima_ns.c
> @@ -43,12 +43,16 @@ int ima_init_namespace(struct ima_namespace *ns)
> ret = register_blocking_lsm_notifier
> (&ns->ima_lsm_policy_notifier);
> if (ret)
> - return ret;
> + goto destroy_cache;
> }
>
> set_bit(IMA_NS_ACTIVE, &ns->ima_ns_flags);
>
> return 0;
> +
> +destroy_cache:
> + kmem_cache_destroy(ns->ns_status_cache);
> + return ret;
> }
>
> int __init ima_ns_init(void)
Since it doesn't make sense for me to carry a fix patch in this series I will merge this patch into the respective patch.
Thanks,
Stefan
next prev parent reply other threads:[~2022-12-28 16:43 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-15 19:31 [PATCH v14 00/26] ima: Namespace IMA with audit support in IMA-ns Stefan Berger
2022-09-15 19:31 ` [PATCH v14 01/26] securityfs: rework dentry creation Stefan Berger
2022-09-15 19:31 ` [PATCH v14 02/26] securityfs: Extend securityfs with namespacing support Stefan Berger
2022-09-15 19:31 ` [PATCH v14 03/26] ima: Define ima_namespace struct and start moving variables into it Stefan Berger
2022-09-15 19:31 ` [PATCH v14 04/26] ima: Move arch_policy_entry into ima_namespace Stefan Berger
2022-09-15 19:32 ` [PATCH v14 05/26] ima: Move ima_htable " Stefan Berger
2022-09-15 19:32 ` [PATCH v14 06/26] ima: Move measurement list related variables " Stefan Berger
2022-09-15 19:32 ` [PATCH v14 07/26] ima: Move some IMA policy and filesystem " Stefan Berger
2022-09-15 19:32 ` [PATCH v14 08/26] ima: Move IMA securityfs files into ima_namespace or onto stack Stefan Berger
2022-09-15 19:32 ` [PATCH v14 09/26] ima: Move ima_lsm_policy_notifier into ima_namespace Stefan Berger
2022-09-15 19:32 ` [PATCH v14 10/26] ima: Switch to lazy lsm policy updates for better performance Stefan Berger
2022-09-15 19:32 ` [PATCH v14 11/26] ima: Define mac_admin_ns_capable() as a wrapper for ns_capable() Stefan Berger
2022-09-15 19:32 ` [PATCH v14 12/26] ima: Only accept AUDIT rules for non-init_ima_ns namespaces for now Stefan Berger
2022-09-15 19:32 ` [PATCH v14 13/26] userns: Add pointer to ima_namespace to user_namespace Stefan Berger
2022-09-15 19:32 ` [PATCH v14 14/26] ima: Implement hierarchical processing of file accesses Stefan Berger
2022-09-15 19:32 ` [PATCH v14 15/26] ima: Implement ima_free_policy_rules() for freeing of an ima_namespace Stefan Berger
2022-09-15 19:32 ` [PATCH v14 16/26] ima: Add functions for creating and " Stefan Berger
2022-09-15 19:32 ` [PATCH v14 17/26] integrity/ima: Define ns_status for storing namespaced iint data Stefan Berger
2022-12-24 7:05 ` [PATCH v1 1/1] ima: fix possible memory leak in cache allocating for namespace Denis Semakin
2022-12-26 2:43 ` [RFC PATCH v2] " Denis Semakin
2022-12-28 16:35 ` Stefan Berger [this message]
2022-09-15 19:32 ` [PATCH v14 18/26] integrity: Add optional callback function to integrity_inode_free() Stefan Berger
2022-09-15 19:32 ` [PATCH v14 19/26] ima: Namespace audit status flags Stefan Berger
2022-09-15 19:32 ` [PATCH v14 20/26] ima: Remove unused iints from the integrity_iint_cache Stefan Berger
2022-09-15 19:32 ` [PATCH v14 21/26] ima: Setup securityfs for IMA namespace Stefan Berger
2022-09-15 19:32 ` [PATCH v14 22/26] ima: Introduce securityfs file to activate an " Stefan Berger
2022-09-15 19:32 ` [PATCH v14 23/26] ima: Show owning user namespace's uid and gid when displaying policy Stefan Berger
2022-09-15 19:32 ` [PATCH v14 24/26] ima: Limit number of policy rules in non-init_ima_ns Stefan Berger
2022-09-15 19:32 ` [PATCH v14 25/26] ima: Restrict informational audit messages to init_ima_ns Stefan Berger
2022-09-15 19:32 ` [PATCH v14 26/26] ima: Enable IMA namespaces Stefan Berger
2022-09-16 0:56 ` [PATCH v14 00/26] ima: Namespace IMA with audit support in IMA-ns Casey Schaufler
2022-09-16 10:54 ` Stefan Berger
2022-09-16 13:20 ` Stefan Berger
2022-09-16 17:05 ` Casey Schaufler
2022-09-20 20:08 ` Stefan Berger
2022-12-24 6:59 ` [PATCH v1 1/1] ima: fix possible memory leak in cache allocating for namespace Denis Semakin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=67c54e03-fcaa-acfa-2f8b-f14bcab81d68@linux.ibm.com \
--to=stefanb@linux.ibm.com \
--cc=denis.semakin@huawei-partners.com \
--cc=denis.semakin@huawei.com \
--cc=linux-integrity@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox