mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH master 2/2] efi: loader: bump memory map key on FreePages
Date: Thu, 11 Jun 2026 23:22:01 +0200	[thread overview]
Message-ID: <20260611212206.4103255-2-a.fatoum@barebox.org> (raw)
In-Reply-To: <20260611212206.4103255-1-a.fatoum@barebox.org>

efi_allocate_pages() increments the map key on every allocation, but
efi_free_pages() did not.

A payload that calls FreePages() before ExitBootServices() may thus
pass a stale memory map under a key that barebox still accepts.

Fix this by incrementing the key after a successful free.

Fixes: b880bfb8ed85 ("efi: loader: add memory accounting")
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 efi/loader/memory.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/efi/loader/memory.c b/efi/loader/memory.c
index e8dfd59ee8ca..8931cd1bab52 100644
--- a/efi/loader/memory.c
+++ b/efi/loader/memory.c
@@ -301,6 +301,8 @@ efi_status_t efi_free_pages(uint64_t memory, size_t pages)
 	if (nfreed <= 0)
 		return EFI_INVALID_PARAMETER;
 
+	++efi_memory_map_key;
+
 	return EFI_SUCCESS;
 }
 
-- 
2.47.3




  reply	other threads:[~2026-06-11 21:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-11 21:22 [PATCH master 1/2] efi: loader: release bootm OS staging buffer Ahmad Fatoum
2026-06-11 21:22 ` Ahmad Fatoum [this message]
2026-06-15  7:48 ` Sascha Hauer

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=20260611212206.4103255-2-a.fatoum@barebox.org \
    --to=a.fatoum@barebox.org \
    --cc=barebox@lists.infradead.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