From: Breno Leitao <leitao@debian.org>
To: Ard Biesheuvel <ardb@kernel.org>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Borislav Petkov <bp@suse.de>, Andy Lutomirski <luto@kernel.org>,
Kees Cook <kees@kernel.org>, Tony Luck <tony.luck@intel.com>,
"Guilherme G. Piccoli" <gpiccoli@igalia.com>,
Thomas Gleixner <tglx@kernel.org>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>
Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org,
Breno Leitao <leitao@debian.org>,
kernel-team@meta.com
Subject: [PATCH v3 6/7] efi/runtime-wrappers: honour EFI_RUNTIME_SERVICES in the non-blocking paths
Date: Tue, 16 Jun 2026 05:09:39 -0700 [thread overview]
Message-ID: <20260616-efi_timeout-v3-6-76dd1d26657b@debian.org> (raw)
In-Reply-To: <20260616-efi_timeout-v3-0-76dd1d26657b@debian.org>
Three wrappers call firmware directly instead of going through
__efi_queue_work(), and none of them check whether runtime services are
still enabled: virt_efi_set_variable_nb(),
virt_efi_query_variable_info_nb() and virt_efi_reset_system(). Once a
hang has cleared EFI_RUNTIME_SERVICES - or efi_recover_from_page_fault()
has cleared it on a firmware page fault - these paths still enter the
(possibly wedged) firmware, e.g. an EFI pstore write through the
non-blocking SetVariable() variant, in violation of UEFI's
non-reentrancy rules. reset_system() is reachable too: efi_reboot()
only gates it on the static efi_rt_services_supported() mask, which does
not track the runtime disable.
Check efi_enabled(EFI_RUNTIME_SERVICES) in each before calling into
firmware. Test it after taking efi_runtime_lock rather than before: the
bit is only ever cleared at runtime while that lock is held, so checking
it under the lock avoids racing with a concurrent timeout that clears the
bit and drops the lock.
Suggested-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Breno Leitao <leitao@debian.org>
---
drivers/firmware/efi/runtime-wrappers.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/firmware/efi/runtime-wrappers.c b/drivers/firmware/efi/runtime-wrappers.c
index 2ec5cbdf46d07..2b0a7caf90944 100644
--- a/drivers/firmware/efi/runtime-wrappers.c
+++ b/drivers/firmware/efi/runtime-wrappers.c
@@ -480,6 +480,11 @@ virt_efi_set_variable_nb(efi_char16_t *name, efi_guid_t *vendor, u32 attr,
if (down_trylock(&efi_runtime_lock))
return EFI_NOT_READY;
+ if (!efi_enabled(EFI_RUNTIME_SERVICES)) {
+ up(&efi_runtime_lock);
+ return EFI_DEVICE_ERROR;
+ }
+
efi_runtime_lock_owner = current;
status = efi_call_virt_pointer(efi.runtime, set_variable, name, vendor,
attr, data_size, data);
@@ -519,6 +524,11 @@ virt_efi_query_variable_info_nb(u32 attr, u64 *storage_space,
if (down_trylock(&efi_runtime_lock))
return EFI_NOT_READY;
+ if (!efi_enabled(EFI_RUNTIME_SERVICES)) {
+ up(&efi_runtime_lock);
+ return EFI_DEVICE_ERROR;
+ }
+
efi_runtime_lock_owner = current;
status = efi_call_virt_pointer(efi.runtime, query_variable_info, attr,
storage_space, remaining_space,
@@ -549,6 +559,12 @@ virt_efi_reset_system(int reset_type, efi_status_t status,
return;
}
+ if (!efi_enabled(EFI_RUNTIME_SERVICES)) {
+ pr_warn("EFI Runtime Services are disabled, not invoking reset_system()\n");
+ up(&efi_runtime_lock);
+ return;
+ }
+
efi_runtime_lock_owner = current;
arch_efi_call_virt_setup();
efi_rts_work.efi_rts_id = EFI_RESET_SYSTEM;
--
2.53.0-Meta
next prev parent reply other threads:[~2026-06-16 12:10 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-16 12:09 [PATCH v3 0/7] efi/runtime-wrappers: bound the wait for EFI runtime service calls Breno Leitao
2026-06-16 12:09 ` [PATCH v3 1/7] efi: fix stale reference to efi_recover_from_page_fault() Breno Leitao
2026-06-16 12:09 ` [PATCH v3 2/7] efi/runtime-wrappers: factor out efi_rts_park_worker() Breno Leitao
2026-06-16 12:09 ` [PATCH v3 3/7] efi/runtime-wrappers: handle queue_work() failure with goto exit Breno Leitao
2026-06-16 12:09 ` [PATCH v3 4/7] efi/runtime-wrappers: check EFI_RUNTIME_SERVICES before using efi_rts_work Breno Leitao
2026-06-16 12:09 ` [PATCH v3 5/7] efi/runtime-wrappers: bound the wait for EFI runtime service calls Breno Leitao
2026-07-09 6:56 ` Yeoreum Yun
2026-07-10 10:30 ` Breno Leitao
2026-07-10 10:41 ` Yeoreum Yun
2026-07-10 11:14 ` Breno Leitao
2026-07-10 11:26 ` Yeoreum Yun
2026-07-10 13:47 ` Breno Leitao
2026-07-12 16:25 ` Ard Biesheuvel
2026-07-13 10:03 ` Breno Leitao
2026-06-16 12:09 ` Breno Leitao [this message]
2026-06-16 12:09 ` [PATCH v3 7/7] efi/runtime-wrappers: retire the worker if a wedged call ever returns Breno Leitao
2026-07-01 12:28 ` [PATCH v3 0/7] efi/runtime-wrappers: bound the wait for EFI runtime service calls Breno Leitao
2026-07-09 5:02 ` Ard Biesheuvel
2026-07-10 10:06 ` Breno Leitao
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=20260616-efi_timeout-v3-6-76dd1d26657b@debian.org \
--to=leitao@debian.org \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=bp@suse.de \
--cc=dave.hansen@linux.intel.com \
--cc=gpiccoli@igalia.com \
--cc=hpa@zytor.com \
--cc=ilias.apalodimas@linaro.org \
--cc=kees@kernel.org \
--cc=kernel-team@meta.com \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@kernel.org \
--cc=tony.luck@intel.com \
--cc=x86@kernel.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 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.