From: Shakeel Butt <shakeelb@google.com>
To: Kristen Carlson Accardi <kristen@linux.intel.com>
Cc: linux-sgx@vger.kernel.org, Jarkko Sakkinen <jarkko@kernel.org>,
Dave Hansen <dave.hansen@linux.intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/sgx: Set active memcg prior to shmem allocation
Date: Thu, 19 May 2022 05:36:15 +0000 [thread overview]
Message-ID: <20220519053615.zqwecsooceqzwjdf@google.com> (raw)
In-Reply-To: <20220517164713.4610-1-kristen@linux.intel.com>
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;
> +}
prev parent reply other threads:[~2022-05-19 5:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-17 16:47 Kristen Carlson Accardi
2022-05-17 17:57 ` Dave Hansen
2022-05-19 5:43 ` Shakeel Butt
2022-05-19 20:44 ` Kristen Carlson Accardi
2022-05-19 20:45 ` Kristen Carlson Accardi
2022-05-18 1:24 ` Jarkko Sakkinen
2022-05-19 20:47 ` Kristen Carlson Accardi
2022-05-19 5:36 ` Shakeel Butt [this message]
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=20220519053615.zqwecsooceqzwjdf@google.com \
--to=shakeelb@google.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jarkko@kernel.org \
--cc=kristen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sgx@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@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
all inboxes | Powered by JetHome®