1 |
From e006ac3003080177cf0b673441a4241f77aaecce Mon Sep 17 00:00:00 2001 |
2 |
From: Ding Hui <dinghui@sangfor.com.cn> |
3 |
Date: Tue, 27 Dec 2022 23:09:36 +0800 |
4 |
Subject: efi: fix userspace infinite retry read efivars after EFI runtime services page fault |
5 |
|
6 |
From: Ding Hui <dinghui@sangfor.com.cn> |
7 |
|
8 |
commit e006ac3003080177cf0b673441a4241f77aaecce upstream. |
9 |
|
10 |
After [1][2], if we catch exceptions due to EFI runtime service, we will |
11 |
clear EFI_RUNTIME_SERVICES bit to disable EFI runtime service, then the |
12 |
subsequent routine which invoke the EFI runtime service should fail. |
13 |
|
14 |
But the userspace cat efivars through /sys/firmware/efi/efivars/ will stuck |
15 |
and infinite loop calling read() due to efivarfs_file_read() return -EINTR. |
16 |
|
17 |
The -EINTR is converted from EFI_ABORTED by efi_status_to_err(), and is |
18 |
an improper return value in this situation, so let virt_efi_xxx() return |
19 |
EFI_DEVICE_ERROR and converted to -EIO to invoker. |
20 |
|
21 |
Cc: <stable@vger.kernel.org> |
22 |
Fixes: 3425d934fc03 ("efi/x86: Handle page faults occurring while running EFI runtime services") |
23 |
Fixes: 23715a26c8d8 ("arm64: efi: Recover from synchronous exceptions occurring in firmware") |
24 |
Signed-off-by: Ding Hui <dinghui@sangfor.com.cn> |
25 |
Signed-off-by: Ard Biesheuvel <ardb@kernel.org> |
26 |
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
27 |
--- |
28 |
drivers/firmware/efi/runtime-wrappers.c | 1 + |
29 |
1 file changed, 1 insertion(+) |
30 |
|
31 |
diff --git a/drivers/firmware/efi/runtime-wrappers.c b/drivers/firmware/efi/runtime-wrappers.c |
32 |
index 7feee3d9c2bf..1fba4e09cdcf 100644 |
33 |
--- a/drivers/firmware/efi/runtime-wrappers.c |
34 |
+++ b/drivers/firmware/efi/runtime-wrappers.c |
35 |
@@ -62,6 +62,7 @@ struct efi_runtime_work efi_rts_work; |
36 |
\ |
37 |
if (!efi_enabled(EFI_RUNTIME_SERVICES)) { \ |
38 |
pr_warn_once("EFI Runtime Services are disabled!\n"); \ |
39 |
+ efi_rts_work.status = EFI_DEVICE_ERROR; \ |
40 |
goto exit; \ |
41 |
} \ |
42 |
\ |
43 |
-- |
44 |
2.39.0 |
45 |
|