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 RESEND 4/6] efi_loader: capsule: check the certificate length of an image
Date: Mon, 26 Oct 2026 13:19:16 +0000 [thread overview]
Message-ID: <8747959b-774e-42fc-a51a-ef78efe21e46@gmail.com> (raw)
In-Reply-To: <f58ee8d2-b69f-48a5-99f5-a1bbcd3a920b@gmail.com>
From: Ana Bobillo <anabobillo3@gmail.com>
efi_remove_auth_hdr() skips the authentication header of an image by
the dwLength of its certificate without checking it against the image
size. A dwLength larger than the image makes the image size wrap
around:
- with CONFIG_EFI_CAPSULE_AUTHENTICATE, efi_capsule_authenticate()
then parses dwLength bytes of certificate past the end of the image
before the signature is checked;
- without it, efi_capsule_update_firmware() passes the wrapped image
size on to the FMP driver.
Reject a certificate that does not fit in the image.
Fixes: 04be98bd6bcf ("efi: capsule: Add support for uefi capsule authentication")
Fixes: c2cc60c1f93b ("efi_loader: capsule: remove authentication data")
Signed-off-by: Ana Bobillo <anabobillo3@gmail.com>
---
lib/efi_loader/efi_capsule.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
index a8d57630a6f..a3da22aa396 100644
--- a/lib/efi_loader/efi_capsule.c
+++ b/lib/efi_loader/efi_capsule.c
@@ -270,7 +270,9 @@ static efi_status_t efi_remove_auth_hdr(void **image, efi_uintn_t *image_size)
goto out;
if (auth_hdr->auth_info.hdr.dwLength <=
- offsetof(struct win_certificate_uefi_guid, cert_data))
+ offsetof(struct win_certificate_uefi_guid, cert_data) ||
+ auth_hdr->auth_info.hdr.dwLength >
+ *image_size - sizeof(auth_hdr->monotonic_count))
goto out;
*image = (uint8_t *)*image + sizeof(auth_hdr->monotonic_count) +
next prev parent reply other threads:[~2026-10-26 13:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-26 13:18 [PATCH RESEND 0/6] efi_loader: capsule: check sizes against the capsule Ana Bobillo
2026-10-26 13:18 ` [PATCH RESEND 1/6] efi_loader: capsule: check the size of a capsule file Ana Bobillo
2026-10-26 14:29 ` Ilias Apalodimas
2026-10-26 13:19 ` [PATCH RESEND 2/6] efi_loader: capsule: check the capsule header size Ana Bobillo
2026-10-26 13:19 ` [PATCH RESEND 3/6] efi_loader: capsule: check the FMP capsule against its size Ana Bobillo
2026-10-26 16:23 ` Heinrich Schuchardt
2026-10-26 13:19 ` Ana Bobillo [this message]
2026-10-26 13:19 ` [PATCH RESEND 5/6] efi_loader: firmware: check the FMP payload header size Ana Bobillo
2026-10-26 13:19 ` [PATCH RESEND 6/6] test: lib: add tests for the capsule size checks Ana Bobillo
2026-10-26 16:38 ` Heinrich Schuchardt
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=8747959b-774e-42fc-a51a-ef78efe21e46@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox