From: Petr Pavlu <petr.pavlu@suse.com>
To: Kees Cook <kees@kernel.org>
Cc: Luis Chamberlain <mcgrof@kernel.org>,
Sami Tolvanen <samitolvanen@google.com>,
Daniel Gomez <da.gomez@samsung.com>,
linux-modules@vger.kernel.org, Daniel Gomez <da.gomez@kernel.org>,
linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH] module/decompress: Avoid open-coded kvrealloc()
Date: Thu, 20 Nov 2025 13:31:00 +0100 [thread overview]
Message-ID: <d6632fc3-17e2-4d06-abbc-413bb6478db4@suse.com> (raw)
In-Reply-To: <20251119225439.work.741-kees@kernel.org>
On 11/19/25 11:54 PM, Kees Cook wrote:
> Replace open-coded allocate/copy with kvrealloc().
>
> Signed-off-by: Kees Cook <kees@kernel.org>
> ---
> Cc: Petr Pavlu <petr.pavlu@suse.com>
> Cc: Luis Chamberlain <mcgrof@kernel.org>
> Cc: Sami Tolvanen <samitolvanen@google.com>
> Cc: Daniel Gomez <da.gomez@samsung.com>
> Cc: <linux-modules@vger.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@suse.com>
--
Thanks,
Petr
prev parent reply other threads:[~2025-11-20 12:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-19 22:54 [PATCH] module/decompress: Avoid open-coded kvrealloc() Kees Cook
2025-11-20 12:31 ` Petr Pavlu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d6632fc3-17e2-4d06-abbc-413bb6478db4@suse.com \
--to=petr.pavlu@suse.com \
--cc=da.gomez@kernel.org \
--cc=da.gomez@samsung.com \
--cc=kees@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=samitolvanen@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).