From patchwork Tue Dec 27 15:09:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ding Hui X-Patchwork-Id: 36934 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1441408wrt; Tue, 27 Dec 2022 07:21:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXuFJVSzBd89ZxYyGoZvnfD7NgGckvsXKrO3nQ46jO2DVjPMeWzEYTjyZkaDCNBMxo0oJcaE X-Received: by 2002:a05:6a20:d908:b0:ac:98db:d4cb with SMTP id jd8-20020a056a20d90800b000ac98dbd4cbmr29165092pzb.41.1672154513012; Tue, 27 Dec 2022 07:21:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672154512; cv=none; d=google.com; s=arc-20160816; b=zUf/WNHKpTFnHa9c8EDdWPxP1FLE2LQGtsya02DPV4tOPWZreBrc0jznARC0SfEnhI pKJOCD+vHfMQtoUq5IX+d1F7N/AwlzquJ67A+PShqAnGRlXaAwNC7w+V1IXEt4MzES7q Y5V2uZE9+gkHaLHJ7LzakNdJKbPZ0lFqmialdhBnRPoHPe+39M7aSJnGAoDjYjpb77QX C6HvWg9IaA4/p8/JR8NolAEFeXLRqGSQxEn8OyJ/kheEGHTK/H0jXx7SHkiulKLPOHAF VG+NkogngGgJWuRX3g2I1Y2oLKWYnqn3Y8ZZM18gCsBBB7uLVxDgvmnNi0vrkqwBPvsI EHtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=rcL/EFwuPhi0sCkMYyU9dW5Z7X+JfaTXje53uOlh0NY=; b=A5O5mahRAavfF2DVfWkVXAbzxk62MwV1wSsXZkPkm8bgUQO8Xx4lMrbK6FrluUPsHM xckSMTtsjvUJAde5sVJoW8bVAN5N0VgOuWk9pOK5b9CO+MRuxI0A65vkE5eeUm6O+Y7f jh1PjfCg93ytZrIhjbv8g+aW6fYw0UmAbbHnaPog+qeBtunygbMfUxw3BEt6q/BBYi4o 7spVNAFhIIAjEAn9YtsaadKW8YsI7SoL1NPO40KdxOr4fZqOzmSUFuqbKlf/sxUu+YEr NeeqQs/Oftj7fsa0hxF5wTq4GefLOcAqqBcMLXXfcOKLz4r4e682jijYO7185+5Hfd7Z YVRw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sangfor.com.cn Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v189-20020a6389c6000000b004786230ec58si1720646pgd.169.2022.12.27.07.21.39; Tue, 27 Dec 2022 07:21:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sangfor.com.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229726AbiL0PSr (ORCPT + 99 others); Tue, 27 Dec 2022 10:18:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229533AbiL0PSn (ORCPT ); Tue, 27 Dec 2022 10:18:43 -0500 X-Greylist: delayed 494 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 27 Dec 2022 07:18:40 PST Received: from mail-m11874.qiye.163.com (mail-m11874.qiye.163.com [115.236.118.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D447C2635; Tue, 27 Dec 2022 07:18:40 -0800 (PST) Received: from localhost.localdomain (unknown [IPV6:240e:3b7:3277:2370:7116:d41b:2bcc:5af4]) by mail-m11874.qiye.163.com (Hmail) with ESMTPA id 383653C04DC; Tue, 27 Dec 2022 23:10:16 +0800 (CST) From: Ding Hui To: ardb@kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: sai.praneeth.prakhya@intel.com, Ding Hui Subject: [PATCH] efi: fix userspace infinite retry read efivars after EFI runtime services page fault Date: Tue, 27 Dec 2022 23:09:36 +0800 Message-Id: <20221227150936.19242-1-dinghui@sangfor.com.cn> X-Mailer: git-send-email 2.17.1 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVlCSUlMVhgaHUwaSEpKHxlNQ1UTARMWGhIXJBQOD1 lXWRgSC1lBWUlPSx5BSBlMQUhJTExBSUhMS0FMSkpNQR9PShlBSRkYGEFOGh1PWVdZFhoPEhUdFF lBWU9LSFVKSEpCSEtVSktLVUtZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6OFE6Shw*ET0vTi0uOQxRAwkP GTMaCUhVSlVKTUxJSk5IQ0pNTEJKVTMWGhIXVR8SFRwTDhI7CBoVHB0UCVUYFBZVGBVFWVdZEgtZ QVlJT0seQUgZTEFISUxMQUlITEtBTEpKTUEfT0oZQUkZGBhBThodT1lXWQgBWUFJSUhNNwY+ X-HM-Tid: 0a8554225d302eb0kusn383653c04dc X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753381091024504779?= X-GMAIL-MSGID: =?utf-8?q?1753381091024504779?= 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. [1]: commit 3425d934fc03 ("efi/x86: Handle page faults occurring while running EFI runtime services") [2]: commit 23715a26c8d8 ("arm64: efi: Recover from synchronous exceptions occurring in firmware") Signed-off-by: Ding Hui --- drivers/firmware/efi/runtime-wrappers.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/firmware/efi/runtime-wrappers.c b/drivers/firmware/efi/runtime-wrappers.c index 7feee3d9c2bf..1fba4e09cdcf 100644 --- a/drivers/firmware/efi/runtime-wrappers.c +++ b/drivers/firmware/efi/runtime-wrappers.c @@ -62,6 +62,7 @@ struct efi_runtime_work efi_rts_work; \ if (!efi_enabled(EFI_RUNTIME_SERVICES)) { \ pr_warn_once("EFI Runtime Services are disabled!\n"); \ + efi_rts_work.status = EFI_DEVICE_ERROR; \ goto exit; \ } \ \