linux-sgx.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kristen Carlson Accardi <kristen@linux.intel.com>
To: Shakeel Butt <shakeelb@google.com>
Cc: linux-sgx@vger.kernel.org, Dave Hansen <dave.hansen@intel.com>,
	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>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Linux-MM <linux-mm@kvack.org>, Michal Hocko <mhocko@suse.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86/sgx: Set active memcg prior to shmem allocation
Date: Thu, 19 May 2022 13:44:17 -0700	[thread overview]
Message-ID: <c5cae6916a74251187eef3e46a42212177f42253.camel@linux.intel.com> (raw)
In-Reply-To: <CALvZod40TpW0rX1jvj6GZWtr=nscJFkw_zdvZjbh7GPgd8pLWQ@mail.gmail.com>

On Wed, 2022-05-18 at 22:43 -0700, Shakeel Butt wrote:
> (Fixing the CC list and sending again)
> 
> 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;
> > +}

Thank you for your review. I will incorporate this fix into my next
version.



  reply	other threads:[~2022-05-19 20:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-17 16:47 [PATCH] x86/sgx: Set active memcg prior to shmem allocation 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 [this message]
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

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=c5cae6916a74251187eef3e46a42212177f42253.camel@linux.intel.com \
    --to=kristen@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hannes@cmpxchg.org \
    --cc=hpa@zytor.com \
    --cc=jarkko@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-sgx@vger.kernel.org \
    --cc=mhocko@suse.com \
    --cc=mingo@redhat.com \
    --cc=roman.gushchin@linux.dev \
    --cc=shakeelb@google.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;
as well as URLs for NNTP newsgroup(s).