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] [day] [month] [year] [list]
Message-ID: <aMGxjHIfPU9cbGq1@kernel.org>
Date: Wed, 10 Sep 2025 20:12:44 +0300
From: Jarkko Sakkinen <jarkko@...nel.org>
To: Thorsten Blum <thorsten.blum@...ux.dev>
Cc: Dave Hansen <dave.hansen@...ux.intel.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
	x86@...nel.org, "H. Peter Anvin" <hpa@...or.com>,
	linux-sgx@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] x86/sgx: Replace kmalloc() + copy_from_user() with
 memdup_user()

On Mon, Sep 08, 2025 at 10:12:29PM +0200, Thorsten Blum wrote:
> Replace kmalloc() followed by copy_from_user() with memdup_user() to
> improve and simplify sgx_ioc_enclave_create().
> 
> No functional changes intended.
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@...ux.dev>
> ---
>  arch/x86/kernel/cpu/sgx/ioctl.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/sgx/ioctl.c b/arch/x86/kernel/cpu/sgx/ioctl.c
> index 66f1efa16fbb..e99fc38f1273 100644
> --- a/arch/x86/kernel/cpu/sgx/ioctl.c
> +++ b/arch/x86/kernel/cpu/sgx/ioctl.c
> @@ -164,15 +164,11 @@ static long sgx_ioc_enclave_create(struct sgx_encl *encl, void __user *arg)
>  	if (copy_from_user(&create_arg, arg, sizeof(create_arg)))
>  		return -EFAULT;
>  
> -	secs = kmalloc(PAGE_SIZE, GFP_KERNEL);
> -	if (!secs)
> -		return -ENOMEM;
> -
> -	if (copy_from_user(secs, (void __user *)create_arg.src, PAGE_SIZE))
> -		ret = -EFAULT;
> -	else
> -		ret = sgx_encl_create(encl, secs);
> +	secs = memdup_user((void __user *)create_arg.src, PAGE_SIZE);
> +	if (IS_ERR(secs))
> +		return PTR_ERR(secs);
>  
> +	ret = sgx_encl_create(encl, secs);
>  	kfree(secs);
>  	return ret;
>  }
> -- 
> 2.51.0
> 
> 

Agreed:

Reviewed-by: Jarkko Sakkinen <jarkko@...nel.org>

BR, Jarkko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ