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: <CAK7LNAQzkh+DO7ZBVEgLu63k0H5qB-etV_jpo67k+itLWGAosA@mail.gmail.com>
Date: Sun, 8 Jun 2025 01:04:44 +0900
From: Masahiro Yamada <masahiroy@...nel.org>
To: Jeremy Linton <jeremy.linton@....com>
Cc: linux-kbuild@...r.kernel.org, nathan@...nel.org, nicolas.schier@...ux.dev, 
	linux-kernel@...r.kernel.org, Ard Biesheuvel <ardb@...nel.org>
Subject: Re: [PATCH] scripts: add zboot support to extract-vmlinux

On Fri, May 23, 2025 at 2:29 AM Jeremy Linton <jeremy.linton@....com> wrote:
>
> Zboot compressed kernel images are used for arm kernels on various
> distros.

Are you talking about arm 32 bit here?
(arch/arm/boot/zImage)

> extract-vmlinux fails with those kernels because the wrapped image is
> another PE. While this could be a bit confusing, the tools primary
> purpose of unwrapping and decompressing the contained vmlinux image
> makes it the obvious place for this functionality.
>
> Add a 'file' check in check_vmlinux() that detects a contained PE
> image before trying readelf. Recent file implementations output
> something like:
>
> "Linux kernel ARM64 boot executable Image, little-endian, 4K pages"

Are you talking about arm64 here?

I am confused, as arm64 adopts a simple-compressed image.


Apparently, this patch did not work for me.

$ ./scripts/extract-vmlinux  arch/arm/boot/zImage
extract-vmlinux: Cannot find vmlinux.

The 'file' command says, it is "data".
Is my 'file' command too old?

$ file arch/arm/boot/Image
arch/arm/boot/Image: data


> Which is also a stronger statement than readelf provides so drop that
> part of the comment. At the same time this means that kernel images
> which don't appear to contain a compressed image will be returned
> rather than reporting an error. Which matches the behavior for
> existing ELF files.
>
> Signed-off-by: Jeremy Linton <jeremy.linton@....com>
> Cc: Ard Biesheuvel <ardb@...nel.org>
> ---
>  scripts/extract-vmlinux | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/extract-vmlinux b/scripts/extract-vmlinux
> index 8995cd304e6e..edda1abe226c 100755
> --- a/scripts/extract-vmlinux
> +++ b/scripts/extract-vmlinux
> @@ -12,10 +12,11 @@
>
>  check_vmlinux()
>  {
> -       # Use readelf to check if it's a valid ELF
> -       # TODO: find a better to way to check that it's really vmlinux
> -       #       and not just an elf
> -       readelf -h $1 > /dev/null 2>&1 || return 1
> +       file $1 |grep 'Linux kernel.*boot executable Image' > /dev/null
> +       if [ "$?" -ne "0" ]; then
> +               # Use readelf to check if it's a valid ELF, if 'file' fails
> +               readelf -h $1 > /dev/null 2>&1 || return 1
> +       fi
>
>         cat $1
>         exit 0
> --
> 2.49.0
>


-- 
Best Regards
Masahiro Yamada

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ