[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <DM8PR11MB5750579B7AFDBE49400AE5C6E79FA@DM8PR11MB5750.namprd11.prod.outlook.com>
Date: Tue, 20 May 2025 06:22:00 +0000
From: "Reshetova, Elena" <elena.reshetova@...el.com>
To: "Huang, Kai" <kai.huang@...el.com>, "Hansen, Dave" <dave.hansen@...el.com>
CC: "seanjc@...gle.com" <seanjc@...gle.com>, "linux-sgx@...r.kernel.org"
<linux-sgx@...r.kernel.org>, "x86@...nel.org" <x86@...nel.org>, "Scarlata,
Vincent R" <vincent.r.scarlata@...el.com>, "Raynor, Scott"
<scott.raynor@...el.com>, "Annapurve, Vishal" <vannapurve@...gle.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>, "Mallick, Asit
K" <asit.k.mallick@...el.com>, "Aktas, Erdem" <erdemaktas@...gle.com>, "Cai,
Chong" <chongc@...gle.com>, "bondarn@...gle.com" <bondarn@...gle.com>,
"jarkko@...nel.org" <jarkko@...nel.org>, "dionnaglaze@...gle.com"
<dionnaglaze@...gle.com>
Subject: RE: [PATCH v5 1/5] x86/sgx: Introduce a counter to count the
sgx_(vepc_)open()
> > > > diff --git a/arch/x86/kernel/cpu/sgx/driver.c
> > > b/arch/x86/kernel/cpu/sgx/driver.c
> > > > index 7f8d1e11dbee..b5ffe104af4c 100644
> > > > --- a/arch/x86/kernel/cpu/sgx/driver.c
> > > > +++ b/arch/x86/kernel/cpu/sgx/driver.c
> > > > @@ -19,6 +19,7 @@ static int sgx_open(struct inode *inode, struct file
> *file)
> > > > struct sgx_encl *encl;
> > > > int ret;
> > > >
> > > > + sgx_inc_usage_count();
> > >
> > > This should be done at the end of sgx_open() where the open cannot fail,
> > > since
> > > sgx_release() is not called if sgx_open() failed AFAICT.
> >
> >
> > Could you please elaborate a bit more on this?
> > In case sgx_inc_usage_count fails, we dont allocate resources yet, so what is
> > wrong?
> >
>
> I haven't looked into (details of) the last patch yet, but for _this_ patch
> only, doing sgx_inc_usage_count() at the beginning of sgx_open() will result in
> the usage count being increased even when sgx_open() fails at a later time.
> Since sgx_release() is not called when sgx_open() fails, the usage count will
> not be decreased correctly.
>
> No?
Yes, I already yesterday understood that you meant *this* patch and
yes, you are correct in this patch it must be moved to the end that we
don't increment in case of failures.
Powered by blists - more mailing lists