From: Ard Biesheuvel <ardb+git@google.com>
To: linux-efi@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com,
will@kernel.org, catalin.marinas@arm.com,
Ard Biesheuvel <ardb@kernel.org>
Subject: [PATCH v2] arm64/mm: Treat faults taken by EFI runtime firmware as kernel faults
Date: Tue, 13 Oct 2026 09:30:08 +0200 [thread overview]
Message-ID: <20261013073007.1431719-2-ardb+git@google.com> (raw)
From: Ard Biesheuvel <ardb@kernel.org>
When EFI runtime services are invoked from a preemptible kthread, the
kthread runs with efi_mm installed via kthread_use_mm() and preemption
enabled, so neither faulthandler_disabled() nor !mm applies in
do_page_fault(). A permission fault taken by the firmware on one of its
own (TTBR0) mappings then hits the 'access to user memory outside
uaccess routines' check and oopses, without efi_runtime_fixup_exception()
ever being consulted.
efi_mm has no VMAs, so there is nothing for the mm to resolve. Send such
faults to no_context directly, so that __do_kernel_fault() can recover
from them as it does when the call is made with preemption disabled.
Fixes: a5baf582f4c0 ("arm64/efi: Call EFI runtime services without disabling preemption")
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/arm64/mm/fault.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index 0b52557652be..87b5fd77d9ca 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -616,9 +616,10 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr,
/*
* If we're in an interrupt or have no user context, we must not take
- * the fault.
+ * the fault. EFI runtime services may execute with preemption enabled
+ * and mm == &efi_mm, but faults need to be treated as kernel faults.
*/
- if (faulthandler_disabled() || !mm)
+ if (faulthandler_disabled() || !mm || mm_is_efi(mm))
goto no_context;
if (user_mode(regs))
--
2.56.0.385.gd3acb90ef8-goog
next reply other threads:[~2026-10-13 7:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 7:30 Ard Biesheuvel [this message]
2026-10-13 10:14 ` [PATCH v2] arm64/mm: Treat faults taken by EFI runtime firmware as kernel faults Catalin Marinas
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=20261013073007.1431719-2-ardb+git@google.com \
--to=ardb+git@google.com \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-efi@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=will@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.