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: <83553a7287b495326a2f923afd3f6aec9cabd69e.camel@intel.com>
Date: Thu, 24 Jul 2025 10:24:52 +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 v9 2/6] x86/sgx: Introduce a counter to count the
 sgx_(vepc_)open()


>  
> +static int sgx_open(struct inode *inode, struct file *file)
> +{
> +	int ret;
> +
> +	ret = sgx_inc_usage_count();
> +	if (ret)
> +		return ret;
> +
> +	ret = __sgx_open(inode, file);
> +	if (ret) {
> +		sgx_dec_usage_count();
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
>  static int sgx_release(struct inode *inode, struct file *file)
>  {
>  	struct sgx_encl *encl = file->private_data;
> @@ -126,7 +143,7 @@ static long sgx_compat_ioctl(struct file *filep, unsigned int cmd,
>  
>  static const struct file_operations sgx_encl_fops = {
>  	.owner			= THIS_MODULE,
> -	.open			= __sgx_open,
> +	.open			= sgx_open,

If you merge the first patch to this one, you can avoid such chunk in the
diff.

In fact, I think merging the first patch to this one makes sense because
__sgx_open() only makes sense when you have sgx_inc_usage_count().

[...]

>  
> +/* Counter to count the active SGX users */
> +static int __maybe_unused sgx_usage_count;

As replied to the patch 6, I think you can just introduce this variable in
that patch.

> +
> +int sgx_inc_usage_count(void)
> +{
> +	return 0;
> +}
> +
> +void sgx_dec_usage_count(void)
> +{
> +	return;
> +}
> +
> 

[...]

> @@ -265,6 +266,7 @@ static int __sgx_vepc_open(struct inode *inode, struct file *file)
>  	vepc = kzalloc(sizeof(struct sgx_vepc), GFP_KERNEL);
>  	if (!vepc)
>  		return -ENOMEM;
> +

Unintended change?

>  	mutex_init(&vepc->lock);
>  	xa_init(&vepc->page_array);
>  
> @@ -273,6 +275,23 @@ static int __sgx_vepc_open(struct inode *inode, struct file *file)
>  	return 0;
>  }
>  
> +static int sgx_vepc_open(struct inode *inode, struct file *file)
> +{
> +	int ret;
> +
> +	ret = sgx_inc_usage_count();
> +	if (ret)
> +		return ret;
> +
> +	ret =  __sgx_vepc_open(inode, file);
> +	if (ret) {
> +		sgx_dec_usage_count();
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
>  static long sgx_vepc_ioctl(struct file *file,
>  			   unsigned int cmd, unsigned long arg)
>  {
> @@ -291,7 +310,7 @@ static long sgx_vepc_ioctl(struct file *file,
>  
>  static const struct file_operations sgx_vepc_fops = {
>  	.owner		= THIS_MODULE,
> -	.open		= __sgx_vepc_open,
> +	.open		= sgx_vepc_open,

Ditto to sgx_open().

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ