Linux EFI development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ard Biesheuvel" <ardb+git@google.com>, linux-efi@vger.kernel.org
Cc: "Ard Biesheuvel" <ardb@kernel.org>,
	"Jason Gunthorpe" <jgg@nvidia.com>,
	"Paul Walmsley" <pjw@kernel.org>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	"Huacai Chen" <chenhuacai@kernel.org>
Subject: Re: [PATCH v3 06/15] efi/libstub: Capture loaded image information in struct efi_image_info
Date: Mon, 16 Nov 2026 14:59:15 +0000	[thread overview]
Message-ID: <sashiko-outbox-217208@kernel.org> (raw)
In-Reply-To: <20261116142618.1687025-23-ardb+git@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] efi/libstub: broken kernel base address in efi_stub_common() on
  32-bit ARM
--

commit 10e52dbaf9d058d012ab6c3df52814b120d5f9e3
Author: Ard Biesheuvel <ardb@kernel.org>

efi/libstub: Capture loaded image information in struct efi_image_info

This commit introduces struct efi_image_info to hold loaded kernel image
offsets and passes it to efi_stub_common() in place of the raw image base
address.

> diff --git a/drivers/firmware/efi/libstub/arm32-stub.c b/drivers/firmware/efi/libstub/arm32-stub.c
> index 1073dd9475160..f7151a4915ba2 100644
> --- a/drivers/firmware/efi/libstub/arm32-stub.c
> +++ b/drivers/firmware/efi/libstub/arm32-stub.c
> @@ -76,12 +76,15 @@ void efi_handle_post_ebs_state(void)
>  		      &efi_entry_state->sctlr_after_ebs);
>  }
>  
> +struct efi_image_info efistub_image_info = {};
> +
>  efi_status_t handle_kernel_image(unsigned long *image_addr,
>  				 unsigned long *image_size,
>  				 unsigned long *reserve_addr,
>  				 unsigned long *reserve_size,
>  				 efi_loaded_image_t *image,
> -				 efi_handle_t image_handle)
> +				 efi_handle_t image_handle,
> +				 const struct efi_image_info **image_info)

[ ... ]

> diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c
> index 6db10590f89b2..bf9a9f53a95cc 100644
> --- a/drivers/firmware/efi/libstub/efi-stub.c
> +++ b/drivers/firmware/efi/libstub/efi-stub.c
> @@ -160,9 +161,10 @@ efi_status_t efi_handle_cmdline(efi_loaded_image_t *image, char **cmdline_ptr)
>  
>  efi_status_t efi_stub_common(efi_handle_t handle,
>  			     efi_loaded_image_t *image,
> -			     unsigned long image_addr,
> +			     const struct efi_image_info *image_info,
>  			     char *cmdline_ptr)
>  {
> +	unsigned long image_addr = efistub_kernel_base(image_info);

[Severity: High]
Does efistub_kernel_base(image_info) compute a bogus image_addr on 32-bit
ARM?

In arm32-stub.c, efistub_image_info is zero-initialized and
handle_kernel_image() writes kernel_base + TEXT_OFFSET only to *image_addr,
which efi_pe_entry() no longer passes to efi_stub_common().  As a result,
efistub_kernel_base(image_info) evaluates offset_to_ptr(&image_info->_text_offset)
to &efistub_image_info inside the running zImage decompressor instead of
kernel_base + TEXT_OFFSET.  Passing that address to efi_get_max_initrd_addr()
and efi_boot_kernel() -> efi_enter_kernel() causes the decompressor to
overwrite itself and crash boot.

Even with the follow-up commit "efi/libstub: Pass kernel entrypoint down to
efi_enter_kernel()" setting efistub_image_info._text_offset to the absolute
address kernel_base + TEXT_OFFSET, offset_to_ptr(&image_info->_text_offset)
still adds &image_info->_text_offset to that absolute address, passing a
corrupted image_addr to efi_get_max_initrd_addr(image_addr).

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261116142618.1687025-17-ardb+git@google.com?part=6

  reply	other threads:[~2026-11-16 14:59 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 14:26 [PATCH v3 00/15] efi: Expose loaded image properties via info struct Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 01/15] efi/zboot: arm64: Add missing barrier after cache maintenance Ard Biesheuvel
2026-11-16 14:33   ` sashiko-bot
2026-11-16 14:26 ` [PATCH v3 02/15] riscv: Use _stext not _text to denote the start of kernel code Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 03/15] riscv: Make _text point to the start of the kernel image Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 04/15] efi/riscv: Rename __init_text_end to __inittext_end like other archs Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 05/15] efi/libstub: Avoid _end section marker in library code Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 06/15] efi/libstub: Capture loaded image information in struct efi_image_info Ard Biesheuvel
2026-11-16 14:59   ` sashiko-bot [this message]
2026-11-16 14:26 ` [PATCH v3 07/15] efi/libstub: Pass kernel entrypoint down to efi_enter_kernel() Ard Biesheuvel
2026-11-16 14:39   ` sashiko-bot
2026-11-16 14:26 ` [PATCH v3 08/15] efi/libstub: arm64: Use struct efi_image_info to access image properties Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 09/15] efi/libstub: loongarch: " Ard Biesheuvel
2026-11-16 14:40   ` sashiko-bot
2026-11-16 14:26 ` [PATCH v3 10/15] efi/libstub: riscv: " Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 11/15] efi/libstub: Make efi_remap_image() return efi_status_t Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 12/15] efi/zboot: Disentangle efi_remap_image() from efi_cache_sync_image() Ard Biesheuvel
2026-11-16 14:52   ` sashiko-bot
2026-11-16 14:26 ` [PATCH v3 13/15] efi/libstub: arm64: Drop zboot code_size hack Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 14/15] efi: Make config table based primary display handover ARM-only again Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 15/15] Revert "efi: earlycon: Reprobe after parsing config tables" Ard Biesheuvel

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=sashiko-outbox-217208@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=ardb+git@google.com \
    --cc=ardb@kernel.org \
    --cc=chenhuacai@kernel.org \
    --cc=jgg@nvidia.com \
    --cc=linux-efi@vger.kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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