From: sashiko-bot@kernel.org
To: "Ard Biesheuvel" <ardb+git@google.com>, linux-efi@vger.kernel.org
Cc: mark.rutland@arm.com, will@kernel.org, catalin.marinas@arm.com,
"Ard Biesheuvel" <ardb@kernel.org>,
"Jason Gunthorpe" <jgg@nvidia.com>
Subject: Re: [PATCH 2/5] efi/libstub: Pass a struct efi_image_info to efi_stub_common()
Date: Fri, 06 Nov 2026 14:27:12 +0000 [thread overview]
Message-ID: <sashiko-outbox-201577@kernel.org> (raw)
In-Reply-To: <20261106141936.2744481-9-ardb+git@google.com>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] efi/libstub: freed memory retains RO/XP attributes in
efi_zboot_entry() [1]
--
commit ddd62e73ed528e3f2c2ae65f0467b40b21e1c353
Author: Ard Biesheuvel <ardb@kernel.org>
efi/libstub: Pass a struct efi_image_info to efi_stub_common()
This commit passes a struct efi_image_info pointer from both efi_pe_entry()
and efi_zboot_entry() into efi_stub_common().
> diff --git a/drivers/firmware/efi/libstub/zboot.c b/drivers/firmware/efi/libstub/zboot.c
> index 4a5ffe164873e..97ae706c034ad 100644
> --- a/drivers/firmware/efi/libstub/zboot.c
> +++ b/drivers/firmware/efi/libstub/zboot.c
[ ... ]
> @@ -93,9 +98,15 @@ efi_zboot_entry(efi_handle_t handle, efi_system_table_t *systab)
> }
>
> // Decompress the payload into the newly allocated buffer
> - status = efi_zboot_decompress((void *)image_base, alloc_size) ?:
> - efi_stub_common(handle, image, image_base, cmdline_ptr);
> + status = efi_zboot_decompress((void *)image_base, alloc_size);
> + if (status != EFI_SUCCESS)
> + goto error;
> +
> + auto image_info = zboot_get_image_info(image_base);
> + status = efi_stub_common(handle, image, image_base, cmdline_ptr,
> + image_info);
>
> +error:
> efi_free(alloc_size, image_base);
> return status;
> }
[Severity: High]
This problem wasn't introduced by this patch, but can efi_free() return
pages at image_base to the firmware pool while they still carry EFI_MEMORY_RO
and EFI_MEMORY_XP attributes [1]?
When efi_zboot_decompress() succeeds, it remaps the decompressed image's code
as read-only and its data as non-executable via efi_remap_image(). If
efi_stub_common() then fails, efi_free() frees image_base without clearing
those attributes, and UEFI does not require FreePages() to clear memory
attributes automatically. Later firmware allocations that reuse those pages
(such as during boot fallback) can fault and crash when writing data or
executing code.
[1] https://sashiko.dev/#/bug/linux-e232037c-ef9b-47bd-b6d0-1bea4732c0e2
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261106141936.2744481-7-ardb+git@google.com?part=2
next prev parent reply other threads:[~2026-11-06 14:27 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 14:19 [PATCH 0/5] efi: Expose loaded image properties via info struct Ard Biesheuvel
2026-11-06 14:19 ` [PATCH 1/5] efi/libstub: Make efi_remap_image() return efi_status_t Ard Biesheuvel
2026-11-06 14:36 ` sashiko-bot
2026-11-06 14:19 ` [PATCH 2/5] efi/libstub: Pass a struct efi_image_info to efi_stub_common() Ard Biesheuvel
2026-11-06 14:27 ` sashiko-bot [this message]
2026-11-06 14:19 ` [PATCH 3/5] efi/zboot: Disentangle efi_remap_image() from efi_cache_sync_image() Ard Biesheuvel
2026-11-06 14:34 ` sashiko-bot
2026-11-06 14:19 ` [PATCH 4/5] efi/arm64: Expose struct efi_image_info via the image header Ard Biesheuvel
2026-11-06 14:34 ` Jason Gunthorpe
2026-11-06 15:51 ` Ard Biesheuvel
2026-11-06 17:09 ` Jason Gunthorpe
2026-11-06 14:19 ` [PATCH 5/5] efi/arm64: Drop build and linker script hacks to obtain image code size Ard Biesheuvel
2026-11-06 14:33 ` sashiko-bot
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-201577@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ardb+git@google.com \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=jgg@nvidia.com \
--cc=linux-efi@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=will@kernel.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