lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aCtqI_akUp2CYXIj@kernel.org>
Date: Mon, 19 May 2025 20:28:03 +0300
From: Jarkko Sakkinen <jarkko@...nel.org>
To: "Reshetova, Elena" <elena.reshetova@...el.com>
Cc: "Huang, Kai" <kai.huang@...el.com>,
	"Hansen, Dave" <dave.hansen@...el.com>,
	"Raynor, Scott" <scott.raynor@...el.com>,
	"linux-sgx@...r.kernel.org" <linux-sgx@...r.kernel.org>,
	"Scarlata, Vincent R" <vincent.r.scarlata@...el.com>,
	"x86@...nel.org" <x86@...nel.org>,
	"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>,
	"seanjc@...gle.com" <seanjc@...gle.com>,
	"dionnaglaze@...gle.com" <dionnaglaze@...gle.com>
Subject: Re: [PATCH v5 1/5] x86/sgx: Introduce a counter to count the
 sgx_(vepc_)open()

On Mon, May 19, 2025 at 11:47:32AM +0000, Reshetova, Elena wrote:
> > On Mon, 2025-05-19 at 10:24 +0300, Elena Reshetova wrote:
> > > Currently SGX does not have a global counter to count the
> > > active users from userspace or hypervisor. Implement such a counter,
> > > sgx_usage_count. It will be used by the driver when attempting
> > > to call EUPDATESVN SGX instruction.
> > >
> > > Suggested-by: Sean Christopherson <seanjc@...gle.com>
> > > Signed-off-by: Elena Reshetova <elena.reshetova@...el.com>
> > > ---
> > >  arch/x86/kernel/cpu/sgx/driver.c |  1 +
> > >  arch/x86/kernel/cpu/sgx/encl.c   |  1 +
> > >  arch/x86/kernel/cpu/sgx/main.c   | 14 ++++++++++++++
> > >  arch/x86/kernel/cpu/sgx/sgx.h    |  3 +++
> > >  arch/x86/kernel/cpu/sgx/virt.c   |  2 ++
> > >  5 files changed, 21 insertions(+)
> > >
> > > 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? 

It's fine to do (or even perhaps advicable) to do right at the get go,
before doing anything else, because it is "keep alive counter". I.e.,
I think the call is at the right place.

And now there is a proper rollback procedure, as my previous review
comments have been adressed.

> 
> Best Regards,
> Elena.


BR, Jarkko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ