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: <10082c41-4302-4cb3-a2bf-788e59bad0c8@linuxfoundation.org>
Date: Tue, 7 Oct 2025 16:23:32 -0600
From: Shuah Khan <skhan@...uxfoundation.org>
To: Mehdi Ben Hadj Khelifa <mehdi.benhadjkhelifa@...il.com>,
 akpm@...ux-foundation.org
Cc: linux-kernel@...r.kernel.org, david.hunter.linux@...il.com,
 linux-kernel-mentees@...ts.linuxfoundation.org,
 Shuah Khan <skhan@...uxfoundation.org>
Subject: Re: [PATCH] lib: cpu_rmap.c Refactor allocation size calculation in
 kzalloc()

On 9/30/25 03:23, Mehdi Ben Hadj Khelifa wrote:
> Wrap allocation size calculation in size_add() and size_mul() to avoid
> any potential overflow.

How did you find this problem and how did you test this change?
> 
> Signed-off-by: Mehdi Ben Hadj Khelifa <mehdi.benhadjkhelifa@...il.com>
> ---
>   lib/cpu_rmap.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/cpu_rmap.c b/lib/cpu_rmap.c
> index f03d9be3f06b..18b2146a73d2 100644
> --- a/lib/cpu_rmap.c
> +++ b/lib/cpu_rmap.c
> @@ -36,7 +36,7 @@ struct cpu_rmap *alloc_cpu_rmap(unsigned int size, gfp_t flags)
>   	obj_offset = ALIGN(offsetof(struct cpu_rmap, near[nr_cpu_ids]),
>   			   sizeof(void *));
>   
> -	rmap = kzalloc(obj_offset + size * sizeof(rmap->obj[0]), flags);
> +	rmap = kzalloc(size_add(obj_offset, size_mul(size, sizeof(rmap->obj[0]))), flags);
>   	if (!rmap)
>   		return NULL;
>   

thanks,
-- Shuah

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ