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: <cd663aa6-28a1-4c03-9258-511285316c0f@intel.com>
Date: Tue, 29 Oct 2024 11:29:01 +1300
From: "Huang, Kai" <kai.huang@...el.com>
To: Thorsten Blum <thorsten.blum@...ux.dev>, Jarkko Sakkinen
	<jarkko@...nel.org>, 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>
CC: <linux-sgx@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [RESEND PATCH] x86/sgx: Use vmalloc_array() instead of vmalloc()



On 27/10/2024 12:32 am, Thorsten Blum wrote:
> Use vmalloc_array() instead of vmalloc() to calculate the number of
> bytes to allocate.

This says nothing about _why_.  Is it because we want to take advantage 
of the multiplication overflow check inside the vmalloc_array()?

I don't know whether it is implied we should always use vmalloc_array() 
for array allocation like this, i.e., when we see vmalloc() is used for 
array allocation in the kernel we can just write a patch to replace it 
with vmalloc_array() and send to upstream.

I am fine with the code change, though.  So if you can add one more 
sentence to explain why (it's always good to do so), feel free to add:

Acked-by: Kai Huang <kai.huang@...el.com>

> 
> Reviewed-by: Jarkko Sakkinen <jarkko@...nel.org>
> Signed-off-by: Thorsten Blum <thorsten.blum@...ux.dev>
> ---
>   arch/x86/kernel/cpu/sgx/main.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c
> index 9ace84486499..1a59e5956f4b 100644
> --- a/arch/x86/kernel/cpu/sgx/main.c
> +++ b/arch/x86/kernel/cpu/sgx/main.c
> @@ -630,7 +630,7 @@ static bool __init sgx_setup_epc_section(u64 phys_addr, u64 size,
>   	if (!section->virt_addr)
>   		return false;
>   
> -	section->pages = vmalloc(nr_pages * sizeof(struct sgx_epc_page));
> +	section->pages = vmalloc_array(nr_pages, sizeof(struct sgx_epc_page));
>   	if (!section->pages) {
>   		memunmap(section->virt_addr);
>   		return false;


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ