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: <74fd32cecdd42cb45d88a96a1dbb6d74cb39594d.camel@intel.com>
Date: Mon, 11 Aug 2025 10:50:29 +0000
From: "Huang, Kai" <kai.huang@...el.com>
To: "Reshetova, Elena" <elena.reshetova@...el.com>, "Hansen, Dave"
	<dave.hansen@...el.com>
CC: "seanjc@...gle.com" <seanjc@...gle.com>, "mingo@...nel.org"
	<mingo@...nel.org>, "Scarlata, Vincent R" <vincent.r.scarlata@...el.com>,
	"x86@...nel.org" <x86@...nel.org>, "jarkko@...nel.org" <jarkko@...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>,
	"Bondarevska, Nataliia" <bondarn@...gle.com>, "linux-sgx@...r.kernel.org"
	<linux-sgx@...r.kernel.org>, "Raynor, Scott" <scott.raynor@...el.com>
Subject: Re: [PATCH v12 5/5] x86/sgx: Enable automatic SVN updates for SGX
 enclaves


>  
> +/* Mutex to ensure no concurrent EPC accesses during EUPDATESVN */
> +static DEFINE_MUTEX(sgx_svn_lock);
> +
>  int sgx_inc_usage_count(void)
>  {
> +	guard(mutex)(&sgx_svn_lock);
> +
> +	if (sgx_usage_count++ == 0)
> +		return sgx_update_svn();
> +

Hmm.. sorry for not noticing this before.. But I think we might have a
problem here since the sgx_usage_count is increased regardless of the
result of sgx_update_svn().

If sgx_update_svn() fails, it makes sgx_inc_usage_count() return error
too, so sgx_{vepc_}open() will fail and return immediately w/o calling 
sgx_dec_usage_count().

But the sgx_usage_count has been increased.

AFAICT when sgx_{vepc_}_open() fails, the sgx_{vepc_}release() is not
called, so sgx_dec_usage_count() is never called and sgx_usage_count
remains increased.

So when sgx_{vepc_}open() calls sgx_inc_usage_count() again, it will skip
calling sgx_update_svn(), and allow enclave/vEPC to be created
successfully, which just defeats the purpose.

So if I am not missing anything, I think we should only increase the count
when sgx_update_svn() returns success?

>  	return 0;
>  }
>  
>  void sgx_dec_usage_count(void)
>  {
> -	return;
> +	sgx_usage_count--;
>  }
>  
>  static int __init sgx_init(void)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ