render / rpms / edk2

Forked from rpms/edk2 2 months ago
Clone

Blame SOURCES/edk2-NetworkPkg-TlsDxe-Add-the-support-of-host-validation.patch

63d87e
From 24a4a1d62ae749c197f36d72f645c7142f368e6a Mon Sep 17 00:00:00 2001
63d87e
From: Laszlo Ersek <lersek@redhat.com>
63d87e
Date: Mon, 2 Dec 2019 12:32:00 +0100
63d87e
Subject: [PATCH 7/9] NetworkPkg/TlsDxe: Add the support of host validation to
63d87e
 TlsDxe driver (CVE-2019-14553)
63d87e
MIME-Version: 1.0
63d87e
Content-Type: text/plain; charset=UTF-8
63d87e
Content-Transfer-Encoding: 8bit
63d87e
63d87e
RH-Author: Laszlo Ersek <lersek@redhat.com>
63d87e
Message-id: <20191117220052.15700-8-lersek@redhat.com>
63d87e
Patchwork-id: 92456
63d87e
O-Subject: [RHEL-8.2.0 edk2 PATCH 7/9] NetworkPkg/TlsDxe: Add the support of host validation to TlsDxe driver (CVE-2019-14553)
63d87e
Bugzilla: 1536624
63d87e
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
63d87e
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
63d87e
63d87e
From: "Wu, Jiaxin" <jiaxin.wu@intel.com>
63d87e
63d87e
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=960
63d87e
CVE: CVE-2019-14553
63d87e
The new data type named "EfiTlsVerifyHost" and the
63d87e
EFI_TLS_VERIFY_HOST_FLAG are supported in TLS protocol.
63d87e
63d87e
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
63d87e
Reviewed-by: Ye Ting <ting.ye@intel.com>
63d87e
Reviewed-by: Long Qin <qin.long@intel.com>
63d87e
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
63d87e
Acked-by: Laszlo Ersek <lersek@redhat.com>
63d87e
Message-Id: <20190927034441.3096-4-Jiaxin.wu@intel.com>
63d87e
Cc: David Woodhouse <dwmw2@infradead.org>
63d87e
Cc: Jian J Wang <jian.j.wang@intel.com>
63d87e
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
63d87e
Cc: Sivaraman Nainar <sivaramann@amiindia.co.in>
63d87e
Cc: Xiaoyu Lu <xiaoyux.lu@intel.com>
63d87e
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
63d87e
(cherry picked from commit 703e7ab21ff8fda9ababf7751d59bd28ad5da947)
63d87e
---
63d87e
 NetworkPkg/TlsDxe/TlsProtocol.c | 44 ++++++++++++++++++++++++++++++++++++++---
63d87e
 1 file changed, 41 insertions(+), 3 deletions(-)
63d87e
63d87e
diff --git a/NetworkPkg/TlsDxe/TlsProtocol.c b/NetworkPkg/TlsDxe/TlsProtocol.c
63d87e
index a7a993f..001e540 100644
63d87e
--- a/NetworkPkg/TlsDxe/TlsProtocol.c
63d87e
+++ b/NetworkPkg/TlsDxe/TlsProtocol.c
63d87e
@@ -1,7 +1,7 @@
63d87e
 /** @file
63d87e
   Implementation of EFI TLS Protocol Interfaces.
63d87e
 
63d87e
-  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
63d87e
+  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
63d87e
 
63d87e
   SPDX-License-Identifier: BSD-2-Clause-Patent
63d87e
 
63d87e
@@ -56,12 +56,16 @@ TlsSetSessionData (
63d87e
   UINT16                    *CipherId;
63d87e
   CONST EFI_TLS_CIPHER      *TlsCipherList;
63d87e
   UINTN                     CipherCount;
63d87e
+  CONST EFI_TLS_VERIFY_HOST *TlsVerifyHost;
63d87e
+  EFI_TLS_VERIFY            VerifyMethod;
63d87e
+  UINTN                     VerifyMethodSize;
63d87e
   UINTN                     Index;
63d87e
 
63d87e
   EFI_TPL                   OldTpl;
63d87e
 
63d87e
-  Status = EFI_SUCCESS;
63d87e
-  CipherId = NULL;
63d87e
+  Status           = EFI_SUCCESS;
63d87e
+  CipherId         = NULL;
63d87e
+  VerifyMethodSize = sizeof (EFI_TLS_VERIFY);
63d87e
 
63d87e
   if (This == NULL || Data == NULL || DataSize == 0) {
63d87e
     return EFI_INVALID_PARAMETER;
63d87e
@@ -149,6 +153,40 @@ TlsSetSessionData (
63d87e
 
63d87e
     TlsSetVerify (Instance->TlsConn, *((UINT32 *) Data));
63d87e
     break;
63d87e
+  case EfiTlsVerifyHost:
63d87e
+    if (DataSize != sizeof (EFI_TLS_VERIFY_HOST)) {
63d87e
+      Status = EFI_INVALID_PARAMETER;
63d87e
+      goto ON_EXIT;
63d87e
+    }
63d87e
+
63d87e
+    TlsVerifyHost = (CONST EFI_TLS_VERIFY_HOST *) Data;
63d87e
+
63d87e
+    if ((TlsVerifyHost->Flags & EFI_TLS_VERIFY_FLAG_ALWAYS_CHECK_SUBJECT) != 0 &&
63d87e
+        (TlsVerifyHost->Flags & EFI_TLS_VERIFY_FLAG_NEVER_CHECK_SUBJECT) != 0) {
63d87e
+      Status = EFI_INVALID_PARAMETER;
63d87e
+      goto ON_EXIT;
63d87e
+    }
63d87e
+
63d87e
+    if ((TlsVerifyHost->Flags & EFI_TLS_VERIFY_FLAG_NO_WILDCARDS) != 0 &&
63d87e
+        ((TlsVerifyHost->Flags & EFI_TLS_VERIFY_FLAG_NO_PARTIAL_WILDCARDS) != 0 ||
63d87e
+         (TlsVerifyHost->Flags & EFI_TLS_VERIFY_FLAG_MULTI_LABEL_WILDCARDS) != 0)) {
63d87e
+      Status = EFI_INVALID_PARAMETER;
63d87e
+      goto ON_EXIT;
63d87e
+    }
63d87e
+
63d87e
+    Status = This->GetSessionData (This, EfiTlsVerifyMethod, &VerifyMethod, &VerifyMethodSize);
63d87e
+    if (EFI_ERROR (Status)) {
63d87e
+      goto ON_EXIT;
63d87e
+    }
63d87e
+
63d87e
+    if ((VerifyMethod & EFI_TLS_VERIFY_PEER) == 0) {
63d87e
+      Status = EFI_INVALID_PARAMETER;
63d87e
+      goto ON_EXIT;
63d87e
+    }
63d87e
+
63d87e
+    Status = TlsSetVerifyHost (Instance->TlsConn, TlsVerifyHost->Flags, TlsVerifyHost->HostName);
63d87e
+
63d87e
+    break;
63d87e
   case EfiTlsSessionID:
63d87e
     if (DataSize != sizeof (EFI_TLS_SESSION_ID)) {
63d87e
       Status = EFI_INVALID_PARAMETER;
63d87e
-- 
63d87e
1.8.3.1
63d87e