[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220519053615.zqwecsooceqzwjdf@google.com>
Date: Thu, 19 May 2022 05:36:15 +0000
From: Shakeel Butt <shakeelb@...gle.com>
To: Kristen Carlson Accardi <kristen@...ux.intel.com>
Cc: linux-sgx@...r.kernel.org, Jarkko Sakkinen <jarkko@...nel.org>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
x86@...nel.org, "H. Peter Anvin" <hpa@...or.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] x86/sgx: Set active memcg prior to shmem allocation
On Tue, May 17, 2022 at 09:47:13AM -0700, Kristen Carlson Accardi wrote:
>
[...]
> +int sgx_encl_alloc_backing(struct sgx_encl *encl, unsigned long page_index,
> + struct sgx_backing *backing)
> +{
> + struct mem_cgroup *old_memcg;
> + int ret;
> +
> + old_memcg = sgx_encl_set_active_memcg(encl);
This function is leaking memcg reference. Please change
sgx_encl_set_active_memcg() to sgx_encl_get_mem_cgroup() or something
which will return the memcg with the refcount elevated. Then use
set_active_memcg(returned_memcg) here.
> +
> + ret = sgx_encl_get_backing(encl, page_index, backing);
> +
> + set_active_memcg(old_memcg);
mem_cgroup_put(returned_memcg) here.
> +
> + return ret;
> +}
Powered by blists - more mailing lists