Linux-EFI Archive on
 help / color / Atom feed
From: Ard Biesheuvel <>
To:, Ingo Molnar <>,
	Thomas Gleixner <>
Cc: Ard Biesheuvel <>,,
	Arvind Sankar <>,
	Hans de Goede <>
Subject: [PATCH 2/3] efi/libstub/random: Initialize pointer variables to zero for mixed mode
Date: Tue, 24 Dec 2019 14:29:08 +0100
Message-ID: <> (raw)
In-Reply-To: <>

From: Hans de Goede <>

Commit 0d95981438c3 ("x86: efi/random: Invoke EFI_RNG_PROTOCOL to seed the
UEFI RNG table"), causes the drivers/efi/libstub/random.c code to get used
on x86 for the first time.

But this code was not written with EFI mixed mode in mind (running a 64
bit kernel on 32 bit EFI firmware), this causes the kernel to crash during
early boot when running in mixed mode.

The problem is that in mixed mode pointers are 64 bit, but when running on
a 32 bit firmware, EFI calls which return a pointer value by reference only
fill the lower 32 bits of the passed pointer, leaving the upper 32 bits
uninitialized which leads to crashes.

This commit fixes this by initializing pointers which are passed by
reference to EFI calls to NULL before passing them, so that the upper 32
bits are initialized to 0.

Fixes: 0d95981438c3 ("x86: efi/random: Invoke EFI_RNG_PROTOCOL to seed the UEFI RNG table")
Signed-off-by: Hans de Goede <>
Signed-off-by: Ard Biesheuvel <>
 drivers/firmware/efi/libstub/random.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/efi/libstub/random.c b/drivers/firmware/efi/libstub/random.c
index 35edd7cfb6a1..97378cf96a2e 100644
--- a/drivers/firmware/efi/libstub/random.c
+++ b/drivers/firmware/efi/libstub/random.c
@@ -33,7 +33,7 @@ efi_status_t efi_get_random_bytes(efi_system_table_t *sys_table_arg,
 	efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID;
 	efi_status_t status;
-	struct efi_rng_protocol *rng;
+	struct efi_rng_protocol *rng = NULL;
 	status = efi_call_early(locate_protocol, &rng_proto, NULL,
 				(void **)&rng);
@@ -162,8 +162,8 @@ efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg)
 	efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID;
 	efi_guid_t rng_algo_raw = EFI_RNG_ALGORITHM_RAW;
 	efi_guid_t rng_table_guid = LINUX_EFI_RANDOM_SEED_TABLE_GUID;
-	struct efi_rng_protocol *rng;
-	struct linux_efi_random_seed *seed;
+	struct efi_rng_protocol *rng = NULL;
+	struct linux_efi_random_seed *seed = NULL;
 	efi_status_t status;
 	status = efi_call_early(locate_protocol, &rng_proto, NULL,

  parent reply index

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-24 13:29 [GIT PULL 0/3] EFI fixes for v5.5 Ard Biesheuvel
2019-12-24 13:29 ` [PATCH 1/3] efi/earlycon: Fix write-combine mapping on x86 Ard Biesheuvel
2019-12-25 10:38   ` [tip: efi/urgent] " tip-bot2 for Arvind Sankar
2019-12-24 13:29 ` Ard Biesheuvel [this message]
2019-12-25 10:38   ` [tip: efi/urgent] efi/libstub/random: Initialize pointer variables to zero for mixed mode tip-bot2 for Hans de Goede
2019-12-24 13:29 ` [PATCH 3/3] x86/efistub: disable paging at mixed mode entry Ard Biesheuvel
2019-12-25 10:38   ` [tip: efi/urgent] x86/efistub: Disable " tip-bot2 for Ard Biesheuvel
2019-12-25  9:50 ` [GIT PULL 0/3] EFI fixes for v5.5 Ingo Molnar

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-EFI Archive on

Archives are clonable:
	git clone --mirror linux-efi/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-efi linux-efi/ \
	public-inbox-index linux-efi

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone