Linux EFI development
 help / color / mirror / Atom feed
From: dev12124 <joaoanandalima@gmail.com>
To: sashiko-reviews@lists.linux.dev
Cc: Ard Biesheuvel <ardb+git@google.com>,
	linux-efi@vger.kernel.org,  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 v4 06/19] efi/libstub: arm: Size the decompressed kernel allocation precisely
Date: Fri, 20 Nov 2026 02:00:04 -0300 (Hora oficial do Brasil)	[thread overview]
Message-ID: <0c221d69-fb50-e266-6054-7ce6360fd677@gmail.com> (raw)
In-Reply-To: <sashiko-outbox-221779@kernel.org>

[-- Attachment #1: Type: text/plain, Size: 1725 bytes --]

Hi Sashiko-bot, Ard,

A few points in arm32-stub.c in your patch:

>> ...
>> ...
>> + extern u32 input_data_end[] __aligned(1);
>> ...
>> ...
>> + unsigned long kernel_memsize = ...
>> ...

I agree with Sashiko Bot Review. In my current tree, I verified:

In vmlinux.lds.S:

.piggydata : {
    (.piggydata)
    __piggy_size_addr = . - 4;
}
  ...
  . = ALIGN(4);
  _etext = .;

In misc.c:

...
 	ret = do_decompress(input_data, input_data_end - input_data,
 		            output_data, error);
         if (ret)
 		error("decompressor returned an error");
 	else
 		putstr(" done, booting the kernel.\n");
...

In arm32-stub.c:

...
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)

 	const int slack = TEXT_OFFSET - 5 * PAGE_SIZE;
 	int alloc_size = MAX_UNCOMP_KERNEL_SIZE + EFI_PHYS_ALIGN;
 	unsigned long alloc_base, kernel_base;
 	efi_status_t status;
...

I. Analysis

    input_data_end sits immediately after .piggydata and right before . = ALIGN(4); in vmlinux.lds.S, so its address is only 1-byte aligned.

    Applying __aligned(1) to extern u32 input_data_end[] does not prevent an unaligned 32-bit word load when input_data_end[-1] decays to
      u32 *, which can trigger an alignment fault on ARM32 during early  stub execution.

II. Suggestion

    Declare extern u8 input_data_end[]; (byte array, naturally 1-byte aligned without attributes) and read the uncompressed size safely
       via get_unaligned_le32(input_data_end - 4) (from <linux/unaligned.h>).

Thanks,
João Guilherme da Silva Freitas Lima <joaoanandalima@gmail.com>

  reply	other threads:[~2026-11-20  5:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 18:21 [PATCH v4 00/19] efi: Expose loaded image properties via info struct Ard Biesheuvel
2026-11-18 18:21 ` [PATCH v4 01/19] efi/zboot: arm64: Add missing barrier after cache maintenance Ard Biesheuvel
2026-11-18 18:28   ` sashiko-bot
2026-11-18 18:21 ` [PATCH v4 02/19] riscv: Use _stext not _text to denote the start of kernel code Ard Biesheuvel
2026-11-18 18:21 ` [PATCH v4 03/19] riscv: Make _text point to the start of the kernel image Ard Biesheuvel
2026-11-18 18:21 ` [PATCH v4 04/19] efi/riscv: Rename __init_text_end to __inittext_end like other archs Ard Biesheuvel
2026-11-18 18:21 ` [PATCH v4 05/19] efi/libstub: Avoid _end section marker in library code Ard Biesheuvel
2026-11-18 18:21 ` [PATCH v4 06/19] efi/libstub: arm: Size the decompressed kernel allocation precisely Ard Biesheuvel
2026-11-18 18:41   ` sashiko-bot
2026-11-20  5:00     ` dev12124 [this message]
2026-11-18 18:21 ` [PATCH v4 07/19] efi/libstub: Avoid reserve_addr/_size in efi_kaslr_relocate_kernel() Ard Biesheuvel
2026-11-18 18:21 ` [PATCH v4 08/19] efi/libstub: Capture loaded image information in struct efi_image_info Ard Biesheuvel
2026-11-18 18:21 ` [PATCH v4 09/19] efi/libstub: Pass kernel entrypoint down to efi_enter_kernel() Ard Biesheuvel
2026-11-18 18:21 ` [PATCH v4 10/19] efi/libstub: arm: Simplify handle_kernel_image() Ard Biesheuvel
2026-11-18 18:21 ` [PATCH v4 11/19] efi/libstub: Drop reserve_addr/_size params from handle_kernel_image() Ard Biesheuvel
2026-11-18 18:21 ` [PATCH v4 12/19] efi/libstub: arm64: Use struct efi_image_info to access image properties Ard Biesheuvel
2026-11-18 18:21 ` [PATCH v4 13/19] efi/libstub: loongarch: " Ard Biesheuvel
2026-11-18 18:21 ` [PATCH v4 14/19] efi/libstub: riscv: " Ard Biesheuvel
2026-11-18 18:21 ` [PATCH v4 15/19] efi/libstub: Make efi_remap_image() return efi_status_t Ard Biesheuvel
2026-11-18 18:21 ` [PATCH v4 16/19] efi/zboot: Disentangle efi_remap_image() from efi_cache_sync_image() Ard Biesheuvel
2026-11-18 18:21 ` [PATCH v4 17/19] efi/libstub: arm64: Drop zboot code_size hack Ard Biesheuvel
2026-11-18 18:21 ` [PATCH v4 18/19] efi: Make config table based primary display handover ARM-only again Ard Biesheuvel
2026-11-18 18:21 ` [PATCH v4 19/19] 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=0c221d69-fb50-e266-6054-7ce6360fd677@gmail.com \
    --to=joaoanandalima@gmail.com \
    --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