From nobody Mon Feb 9 20:32:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+52715+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52715+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1578020685; cv=none; d=zohomail.com; s=zohoarc; b=lnmyBvdgheAeggNRbHvVSsZeQeUut48KlZeqW+cNpMmzXaXVo1qhEJONQi20u6hYTyUkQr5VKXA0bhRiB9X/VzANWxeaabh7bXKDJxvZR8oVPvDer0YmAEhbDUd3QBgdy10qWGETYuvNGsJrwJMZi9lxwyiQsR8Fuw86je+pxGw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578020685; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=oGxqYpVkFvXH4vOsu3HIlpi9MxGupZot+rsjRcOBEHQ=; b=TmypjKDTvW+L6+b60QJ8QwyjikHn93C6/LJvhKQk8IlbRfGw5vDeEZtvZX1J457vSYxjLvA27wancU/7VkaDJMo78QSHhYQ5vUCUlsW3G8olj2/fTtqSn2iXgoGeIFapCVXdWJZK8iE1Pc85beGpYlgJFF5U8j66uvA7Awcgbi8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+52715+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 157802068502662.80331759373996; Thu, 2 Jan 2020 19:04:45 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id zHLhYY1788612x5gh9BGedVx; Thu, 02 Jan 2020 19:04:44 -0800 X-Received: from mga04.intel.com (mga04.intel.com []) by mx.groups.io with SMTP id smtpd.web09.3729.1578020675360032184 for ; Thu, 02 Jan 2020 19:04:44 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jan 2020 19:04:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,389,1571727600"; d="scan'208";a="252455138" X-Received: from fieedk001.ccr.corp.intel.com ([10.239.33.119]) by fmsmga002.fm.intel.com with ESMTP; 02 Jan 2020 19:04:43 -0800 From: "Gao, Zhichao" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang , Chao Zhang Subject: [edk2-devel] [PATCH 08/13] SecurityPkg/TcgPyhsicalPresenceLib: Use Pcd for user resp wait time Date: Fri, 3 Jan 2020 11:04:22 +0800 Message-Id: <20200103030428.28176-9-zhichao.gao@intel.com> In-Reply-To: <20200103030428.28176-1-zhichao.gao@intel.com> References: <20200103030428.28176-1-zhichao.gao@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,zhichao.gao@intel.com X-Gm-Message-State: X47fq4aEGxdaW3IR6Q8ZPAJrx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1578020684; bh=DGIardZcvYcY0wCkIBnWfIVBMKod7LaNqM93EHMYLLE=; h=Cc:Date:From:Reply-To:Subject:To; b=gsEaO/nMQldDsSTpJmSHtvSUjfVGI2iwDvRN1tqJFar/sVqbr1Ho6GxVdw10ssxxhp6 Ef2g7nHWjETgUC8DPOsDP0rlMJgemJiJcpv6B2FQ/wO2ac2sfjj62m7Y1Kzf9OhjO2ULn coMreYNA3HpIxmDmjAdpcp8qIMPYl6KNMhM= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2443 Use the pcd PcdPhysicalPresenceUserConfirmTimeout to control the wait time of user response. Cc: Jiewen Yao Cc: Jian J Wang Cc: Chao Zhang Signed-off-by: Zhichao Gao --- .../DxeTcgPhysicalPresenceLib.c | 76 ++++++++++++------- .../DxeTcgPhysicalPresenceLib.inf | 6 +- 2 files changed, 55 insertions(+), 27 deletions(-) diff --git a/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPr= esenceLib.c b/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalP= resenceLib.c index 174172d5d7..14423991f0 100644 --- a/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceL= ib.c +++ b/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceL= ib.c @@ -8,7 +8,7 @@ =20 ExecutePendingTpmRequest() will receive untrusted input and do validatio= n. =20 -Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -29,6 +29,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include +#include =20 #define CONFIRM_BUFFER_SIZE 4096 =20 @@ -444,35 +446,57 @@ ReadUserKey ( { EFI_STATUS Status; EFI_INPUT_KEY Key; - UINT16 InputKey; - UINTN Index; + UINT16 ConfirmKey; + UINTN Interval; + INT64 Timeout; =20 - InputKey =3D 0; - do { - Status =3D gST->ConIn->ReadKeyStroke (gST->ConIn, &Key); - if (Status =3D=3D EFI_NOT_READY) { - gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &Index); - continue; - } + // + // delay 100 milli-second + // + Interval =3D 100; + ConfirmKey =3D (CautionKey) ? SCAN_F12 : SCAN_F10; + Timeout =3D (INT64)PcdGet32 (PcdPhysicalPresenceUserConfirmTimeout); + if (Timeout > 0) { + Timeout =3D (INT64)MultU64x32 ((UINT64)Timeout, 1000); + } else { + // + // Wait forever + // + Timeout =3D MAX_INT64; + } =20 - if (Status =3D=3D EFI_DEVICE_ERROR) { - return FALSE; - } + // + // Wait for user response within the time-out + // + do { + MicroSecondDelay (Interval * 1000); + + Status =3D gBS->CheckEvent (gST->ConIn->WaitForKey); + if (!EFI_ERROR (Status)) { + Status =3D gST->ConIn->ReadKeyStroke (gST->ConIn, &Key); + if (!EFI_ERROR (Status)) { + if (Key.ScanCode =3D=3D ConfirmKey) { + // + // User Confirmation + // + return TRUE; + } =20 - if (Key.ScanCode =3D=3D SCAN_ESC) { - InputKey =3D Key.ScanCode; - } - if ((Key.ScanCode =3D=3D SCAN_F10) && !CautionKey) { - InputKey =3D Key.ScanCode; - } - if ((Key.ScanCode =3D=3D SCAN_F12) && CautionKey) { - InputKey =3D Key.ScanCode; + if (Key.ScanCode =3D=3D SCAN_ESC) { + // + // User Rejection + // + return FALSE; + } + } else if (Status =3D=3D EFI_DEVICE_ERROR) { + // + // If error, assume User Rejection + // + return FALSE; + } } - } while (InputKey =3D=3D 0); - - if (InputKey !=3D SCAN_ESC) { - return TRUE; - } + Timeout -=3D Interval; + } while (Timeout > 0); =20 return FALSE; } diff --git a/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPr= esenceLib.inf b/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysica= lPresenceLib.inf index cfe14f20ca..13b7246290 100644 --- a/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceL= ib.inf +++ b/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceL= ib.inf @@ -9,7 +9,7 @@ # This driver will have external input - variable. # This external input must be validated carefully to avoid security issue. # -# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -50,11 +50,15 @@ PrintLib HiiLib TcgPpVendorLib + TimerLib =20 [Protocols] gEfiTcgProtocolGuid ## SOMETIMES_CONSUMES gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES =20 +[Pcd] + gEfiSecurityPkgTokenSpaceGuid.PcdPhysicalPresenceUserConfirmTimeout + [Guids] ## SOMETIMES_CONSUMES ## HII ## SOMETIMES_PRODUCES ## Variable:L"PhysicalPresence" --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#52715): https://edk2.groups.io/g/devel/message/52715 Mute This Topic: https://groups.io/mt/69392335/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-