* [PATCH] efi: Wipe INITRD config table from memory after consumption
@ 2025-12-05 9:32 Ard Biesheuvel
2026-01-08 11:42 ` Ard Biesheuvel
0 siblings, 1 reply; 2+ messages in thread
From: Ard Biesheuvel @ 2025-12-05 9:32 UTC (permalink / raw)
To: linux-efi; +Cc: x86, Ard Biesheuvel, James Le Cuirot, H. Peter Anvin (Intel)
When the EFI stub itself loads the initrd and puts it in memory (rather
than simply passing on a struct boot_params or device tree that already
carries initrd information), it exposes this information to the core
kernel via a INITRD configuration table.
Given that config tables are preserved across kexec, this means that
subsequent kexec boots will observe the same information, even though it
most likely has become stale by that point. On x86, this information is
usually superseded by the initrd info passed via bootparams, in which
case this stale information is simply ignored. However, when performing
a kexec boot without passing an initrd, the loader falls back to this
stale information and explodes.
So wipe the base and size from the INITRD config table as soon as it has
been consumed. This fixes the issue for kexec on all EFI architectures.
Reported-by: James Le Cuirot <chewi@gentoo.org>
Tested-by: James Le Cuirot <chewi@gentoo.org>
Acked-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Link: https://lore.kernel.org/all/20251126173209.374755-2-chewi@gentoo.org
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
drivers/firmware/efi/efi.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index a9070d00b833..988198c36a63 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -818,6 +818,7 @@ int __init efi_config_parse_tables(const efi_config_table_t *config_tables,
if (tbl) {
phys_initrd_start = tbl->base;
phys_initrd_size = tbl->size;
+ tbl->base = tbl->size = 0;
early_memunmap(tbl, sizeof(*tbl));
}
}
--
2.47.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] efi: Wipe INITRD config table from memory after consumption
2025-12-05 9:32 [PATCH] efi: Wipe INITRD config table from memory after consumption Ard Biesheuvel
@ 2026-01-08 11:42 ` Ard Biesheuvel
0 siblings, 0 replies; 2+ messages in thread
From: Ard Biesheuvel @ 2026-01-08 11:42 UTC (permalink / raw)
To: linux-efi; +Cc: x86, James Le Cuirot, H. Peter Anvin (Intel)
On Fri, 5 Dec 2025 at 10:32, Ard Biesheuvel <ardb@kernel.org> wrote:
>
> When the EFI stub itself loads the initrd and puts it in memory (rather
> than simply passing on a struct boot_params or device tree that already
> carries initrd information), it exposes this information to the core
> kernel via a INITRD configuration table.
>
> Given that config tables are preserved across kexec, this means that
> subsequent kexec boots will observe the same information, even though it
> most likely has become stale by that point. On x86, this information is
> usually superseded by the initrd info passed via bootparams, in which
> case this stale information is simply ignored. However, when performing
> a kexec boot without passing an initrd, the loader falls back to this
> stale information and explodes.
>
> So wipe the base and size from the INITRD config table as soon as it has
> been consumed. This fixes the issue for kexec on all EFI architectures.
>
> Reported-by: James Le Cuirot <chewi@gentoo.org>
> Tested-by: James Le Cuirot <chewi@gentoo.org>
> Acked-by: H. Peter Anvin (Intel) <hpa@zytor.com>
> Link: https://lore.kernel.org/all/20251126173209.374755-2-chewi@gentoo.org
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> ---
> drivers/firmware/efi/efi.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
> index a9070d00b833..988198c36a63 100644
> --- a/drivers/firmware/efi/efi.c
> +++ b/drivers/firmware/efi/efi.c
> @@ -818,6 +818,7 @@ int __init efi_config_parse_tables(const efi_config_table_t *config_tables,
> if (tbl) {
> phys_initrd_start = tbl->base;
> phys_initrd_size = tbl->size;
> + tbl->base = tbl->size = 0;
> early_memunmap(tbl, sizeof(*tbl));
> }
> }
I had forgotten about this, I've queued it up now.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-01-08 11:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-05 9:32 [PATCH] efi: Wipe INITRD config table from memory after consumption Ard Biesheuvel
2026-01-08 11:42 ` Ard Biesheuvel
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.