mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kees Cook <kees@kernel.org>
To: Haiyue Wang <haiyuewa@163.com>,
	Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org,
	Lasse Collin <lasse.collin@tukaani.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH v1] xz: fix arm fdt compile error for kmalloc replacement
Date: Sun, 22 Feb 2026 10:03:05 -0800	[thread overview]
Message-ID: <202602220940.FB0995939B@keescook> (raw)
In-Reply-To: <20260222121107.116775-1-haiyuewa@163.com>

On Sun, Feb 22, 2026 at 08:11:00PM +0800, Haiyue Wang wrote:
> Align to the commit bf4afc53b77a ("Convert 'alloc_obj' family to use the new default GFP_KERNEL argument")
> update the 'kmalloc_obj' declaration for userspace to fix below comiple error:
> 
> In file included from arch/arm/boot/compressed/../../../../lib/decompress_unxz.c:241,
>                  from arch/arm/boot/compressed/decompress.c:56:
> arch/arm/boot/compressed/../../../../lib/xz/xz_dec_stream.c: In function 'xz_dec_init':
> arch/arm/boot/compressed/../../../../lib/xz/xz_dec_stream.c:787:28: error: implicit declaration of function 'kmalloc_obj'; did you mean 'kmalloc'? [-Wimplicit-function-declaration]
>    787 |         struct xz_dec *s = kmalloc_obj(*s);
>        |                            ^~~~~~~~~~~
>        |                            kmalloc
> [...]
> CC      arch/arm/boot/compressed/fdt.o

Which config & build target was this exposed by? I don't see it with
either "all" nor "zImage" for defconfig (which includes CONFIG_RD_XZ)
nor allmodconfig, and I see arch/arm/boot/compressed/fdt.o getting built.

Okay, I traced down the includes now, it looks like it's tripped by
CONFIG_KERNEL_XZ=y, which isn't in defconfig nor allmodconfig. :(

> Fixes: 69050f8d6d07 ("treewide: Replace kmalloc with kmalloc_obj for non-scalar types")

Also:

Fixes: bf4afc53b77a ("Convert 'alloc_obj' family to use the new default GFP_KERNEL argument")

> Signed-off-by: Haiyue Wang <haiyuewa@163.com>
> ---
>  lib/decompress_unxz.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/decompress_unxz.c b/lib/decompress_unxz.c
> index 32138bb8ef77..05d5cb490a44 100644
> --- a/lib/decompress_unxz.c
> +++ b/lib/decompress_unxz.c
> @@ -157,11 +157,11 @@
>   * when XZ_DYNALLOC is used, but the pre-boot free() doesn't support it.
>   * Workaround it here because the other decompressors don't need it.
>   */
> -#undef kmalloc
> +#undef kmalloc_obj
>  #undef kfree
>  #undef vmalloc
>  #undef vfree
> -#define kmalloc(size, flags) malloc(size)
> +#define kmalloc_obj(type) malloc(sizeof(type))

It may be worth defining this as:

#define kmalloc_obj(type, ...) malloc(sizeof(type))

In case some non-GFP_KERNEL ever end up in here.

Either way:

Reviewed-by: Kees Cook <kees@kernel.org>

-- 
Kees Cook

      parent reply	other threads:[~2026-02-22 18:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-22 12:11 Haiyue Wang
2026-02-22 17:51 ` Lasse Collin
2026-02-22 18:03 ` Kees Cook [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=202602220940.FB0995939B@keescook \
    --to=kees@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=haiyuewa@163.com \
    --cc=lasse.collin@tukaani.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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

all inboxes | Powered by JetHome®