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: <d6632fc3-17e2-4d06-abbc-413bb6478db4@suse.com>
Date: Thu, 20 Nov 2025 13:31:00 +0100
From: Petr Pavlu <petr.pavlu@...e.com>
To: Kees Cook <kees@...nel.org>
Cc: Luis Chamberlain <mcgrof@...nel.org>,
 Sami Tolvanen <samitolvanen@...gle.com>, Daniel Gomez
 <da.gomez@...sung.com>, linux-modules@...r.kernel.org,
 Daniel Gomez <da.gomez@...nel.org>, linux-kernel@...r.kernel.org,
 linux-hardening@...r.kernel.org
Subject: Re: [PATCH] module/decompress: Avoid open-coded kvrealloc()

On 11/19/25 11:54 PM, Kees Cook wrote:
> Replace open-coded allocate/copy with kvrealloc().
> 
> Signed-off-by: Kees Cook <kees@...nel.org>
> ---
> Cc: Petr Pavlu <petr.pavlu@...e.com>
> Cc: Luis Chamberlain <mcgrof@...nel.org>
> Cc: Sami Tolvanen <samitolvanen@...gle.com>
> Cc: Daniel Gomez <da.gomez@...sung.com>
> Cc: <linux-modules@...r.kernel.org>
> ---
>  kernel/module/decompress.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel/module/decompress.c b/kernel/module/decompress.c
> index 474e68f0f063..36f52a232a12 100644
> --- a/kernel/module/decompress.c
> +++ b/kernel/module/decompress.c
> @@ -17,16 +17,16 @@
>  static int module_extend_max_pages(struct load_info *info, unsigned int extent)
>  {
>  	struct page **new_pages;
> +	unsigned int new_max = info->max_pages + extent;
>  
> -	new_pages = kvmalloc_array(info->max_pages + extent,
> -				   sizeof(info->pages), GFP_KERNEL);
> +	new_pages = kvrealloc(info->pages,
> +			      size_mul(new_max, sizeof(*info->pages)),
> +			      GFP_KERNEL);

Nit: Using the array_size() alias of size_mul() might be clearer in this
context.

It looks ok to me in any case.

Reviewed-by: Petr Pavlu <petr.pavlu@...e.com>

-- 
Thanks,
Petr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ