From: Ana Bobillo <anabobillo3@gmail.com>
To: u-boot@lists.u-boot-project.org
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Tom Rini <trini@konsulko.com>
Subject: [PATCH v2 2/7] efi_loader: capsule: check the capsule header size
Date: Wed, 28 Oct 2026 05:49:55 +0000 [thread overview]
Message-ID: <60ff1e72-dead-4ab8-a1a2-e6dfbac3dc91@gmail.com> (raw)
In-Reply-To: <ab256ba2-8572-4cda-b7da-45b2c0368beb@gmail.com>
From: Ana Bobillo <anabobillo3@gmail.com>
On the capsule on disk path, efi_capsule_update_firmware() is called
without the header checks of efi_update_capsule(). It only checks
header_size against the size of the FMP capsule header, so a
header_size smaller than struct efi_capsule_header is accepted, and the
empty capsules of the FWU multi bank update are handled before any
check at all: fwu_empty_capsule_process() reads the image GUID of an
accept capsule at header_size, which may lie anywhere after the
capsule.
Check that header_size covers the capsule header and lies within the
capsule before handling any capsule, and that an accept capsule holds
the image GUID.
Fixes: 8d99026f0697 ("efi_loader: capsule: support firmware update")
Fixes: 86794052418b ("FWU: Add support for the FWU Multi Bank Update feature")
Signed-off-by: Ana Bobillo <anabobillo3@gmail.com>
---
lib/efi_loader/efi_capsule.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
index 54c118736cf..e8835315e86 100644
--- a/lib/efi_loader/efi_capsule.c
+++ b/lib/efi_loader/efi_capsule.c
@@ -445,7 +445,14 @@ static __maybe_unused efi_status_t fwu_empty_capsule_process(
/*
* Image accepted by the OS. Set the acceptance
* status for the image.
+ *
+ * The caller has checked that header_size does not exceed
+ * capsule_image_size.
*/
+ if (capsule->capsule_image_size - capsule->header_size <
+ sizeof(*image_guid))
+ return EFI_INVALID_PARAMETER;
+
image_guid = (void *)(char *)capsule +
capsule->header_size;
@@ -544,6 +551,11 @@ static efi_status_t efi_capsule_update_firmware(
uint update_index;
bool fw_accept_os;
+ /* sanity check */
+ if (capsule_data->header_size < sizeof(*capsule_data) ||
+ capsule_data->header_size > capsule_data->capsule_image_size)
+ return EFI_INVALID_PARAMETER;
+
if (IS_ENABLED(CONFIG_FWU_MULTI_BANK_UPDATE)) {
if (fwu_empty_capsule(capsule_data)) {
if (fwu_empty_capsule_checks_pass()) {
next prev parent reply other threads:[~2026-10-28 5:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 5:49 [PATCH v2 0/7] efi_loader: capsule: check sizes against the capsule Ana Bobillo
2026-10-28 5:49 ` [PATCH v2 1/7] efi_loader: capsule: check the size of a capsule file Ana Bobillo
2026-10-28 5:49 ` Ana Bobillo [this message]
2026-10-28 5:50 ` [PATCH v2 3/7] efi_loader: capsule: check the FMP capsule against its size Ana Bobillo
2026-10-28 5:50 ` [PATCH v2 4/7] efi_loader: capsule: check the certificate length of an image Ana Bobillo
2026-10-28 5:50 ` [PATCH v2 5/7] efi_loader: firmware: check the FMP payload header size Ana Bobillo
2026-10-28 5:50 ` [PATCH v2 6/7] test: lib: add tests for the capsule size checks Ana Bobillo
2026-10-28 5:50 ` [PATCH v2 7/7] test: py: efi_capsule: test truncated capsules and FMP payload headers Ana Bobillo
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=60ff1e72-dead-4ab8-a1a2-e6dfbac3dc91@gmail.com \
--to=anabobillo3@gmail.com \
--cc=ilias.apalodimas@linaro.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.u-boot-project.org \
--cc=xypron.glpk@gmx.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.