]> git.baikalelectronics.ru Git - kernel.git/commit
efi: fix userspace infinite retry read efivars after EFI runtime services page fault
authorDing Hui <dinghui@sangfor.com.cn>
Tue, 27 Dec 2022 15:09:36 +0000 (23:09 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 24 Jan 2023 06:17:59 +0000 (07:17 +0100)
commit280252af752a6dee6227d024080aac5e50b08ec5
tree4741e267b80abb0507f290551856cd3697c3c205
parentf0fb649942ff712e1f7161c49cdc80cb4691cae9
efi: fix userspace infinite retry read efivars after EFI runtime services page fault

[ Upstream commit e006ac3003080177cf0b673441a4241f77aaecce ]

After [1][2], if we catch exceptions due to EFI runtime service, we will
clear EFI_RUNTIME_SERVICES bit to disable EFI runtime service, then the
subsequent routine which invoke the EFI runtime service should fail.

But the userspace cat efivars through /sys/firmware/efi/efivars/ will stuck
and infinite loop calling read() due to efivarfs_file_read() return -EINTR.

The -EINTR is converted from EFI_ABORTED by efi_status_to_err(), and is
an improper return value in this situation, so let virt_efi_xxx() return
EFI_DEVICE_ERROR and converted to -EIO to invoker.

Cc: <stable@vger.kernel.org>
Fixes: 758e32faf330 ("efi/x86: Handle page faults occurring while running EFI runtime services")
Fixes: 796d30f89b2f ("arm64: efi: Recover from synchronous exceptions occurring in firmware")
Signed-off-by: Ding Hui <dinghui@sangfor.com.cn>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/firmware/efi/runtime-wrappers.c