render / rpms / edk2

Forked from rpms/edk2 3 months ago
Clone

Blame SOURCES/edk2-CryptoPkg-Crt-satisfy-inet_pton.c-dependencies-CVE-2.patch

6009e6
From 1ab1024f94401300fe9a1d5cdce6c15a2b091e02 Mon Sep 17 00:00:00 2001
6009e6
From: Laszlo Ersek <lersek@redhat.com>
6009e6
Date: Mon, 2 Dec 2019 12:31:50 +0100
6009e6
Subject: [PATCH 4/9] CryptoPkg/Crt: satisfy "inet_pton.c" dependencies
6009e6
 (CVE-2019-14553)
6009e6
MIME-Version: 1.0
6009e6
Content-Type: text/plain; charset=UTF-8
6009e6
Content-Transfer-Encoding: 8bit
6009e6
6009e6
RH-Author: Laszlo Ersek <lersek@redhat.com>
6009e6
Message-id: <20191117220052.15700-5-lersek@redhat.com>
6009e6
Patchwork-id: 92453
6009e6
O-Subject: [RHEL-8.2.0 edk2 PATCH 4/9] CryptoPkg/Crt: satisfy "inet_pton.c" dependencies (CVE-2019-14553)
6009e6
Bugzilla: 1536624
6009e6
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6009e6
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
6009e6
6009e6
In a later patch in this series, we're going to resurrect "inet_pton.c"
6009e6
(originally from the StdLib package). That source file has a number of
6009e6
standard C and BSD socket dependencies. Provide those dependencies here:
6009e6
6009e6
- The header files below will simply #include <CrtLibSupport.h>:
6009e6
6009e6
  - arpa/inet.h
6009e6
  - arpa/nameser.h
6009e6
  - netinet/in.h
6009e6
  - sys/param.h
6009e6
  - sys/socket.h
6009e6
6009e6
- EAFNOSUPPORT comes from "StdLib/Include/errno.h", at commit
6009e6
  e2d3a25f1a31; which is the commit immediately preceding the removal of
6009e6
  StdLib from edk2 (964f432b9b0a).
6009e6
6009e6
  Note that the other error macro, which we alread #define, namely EINVAL,
6009e6
  has a value (22) that also matches "StdLib/Include/errno.h".
6009e6
6009e6
- The AF_INET and AF_INET6 address family macros come from
6009e6
  "StdLib/Include/sys/socket.h".
6009e6
6009e6
- The NS_INT16SZ, NS_INADDRSZ and NS_IN6ADDRSZ macros come from
6009e6
  "StdLib/Include/arpa/nameser.h".
6009e6
6009e6
- The "u_int" and "u_char" types come from "StdLib/Include/sys/types.h".
6009e6
6009e6
Cc: David Woodhouse <dwmw2@infradead.org>
6009e6
Cc: Jian J Wang <jian.j.wang@intel.com>
6009e6
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
6009e6
Cc: Sivaraman Nainar <sivaramann@amiindia.co.in>
6009e6
Cc: Xiaoyu Lu <xiaoyux.lu@intel.com>
6009e6
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=960
6009e6
CVE: CVE-2019-14553
6009e6
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
6009e6
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
6009e6
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
6009e6
(cherry picked from commit 2ac41c12c0d4b3d3ee8f905ab80da019e784de00)
6009e6
---
6009e6
 CryptoPkg/Library/Include/CrtLibSupport.h | 16 ++++++++++++++++
6009e6
 CryptoPkg/Library/Include/arpa/inet.h     |  9 +++++++++
6009e6
 CryptoPkg/Library/Include/arpa/nameser.h  |  9 +++++++++
6009e6
 CryptoPkg/Library/Include/netinet/in.h    |  9 +++++++++
6009e6
 CryptoPkg/Library/Include/sys/param.h     |  9 +++++++++
6009e6
 CryptoPkg/Library/Include/sys/socket.h    |  9 +++++++++
6009e6
 6 files changed, 61 insertions(+)
6009e6
 create mode 100644 CryptoPkg/Library/Include/arpa/inet.h
6009e6
 create mode 100644 CryptoPkg/Library/Include/arpa/nameser.h
6009e6
 create mode 100644 CryptoPkg/Library/Include/netinet/in.h
6009e6
 create mode 100644 CryptoPkg/Library/Include/sys/param.h
6009e6
 create mode 100644 CryptoPkg/Library/Include/sys/socket.h
6009e6
6009e6
diff --git a/CryptoPkg/Library/Include/CrtLibSupport.h b/CryptoPkg/Library/Include/CrtLibSupport.h
6009e6
index b90da20..e603fad 100644
6009e6
--- a/CryptoPkg/Library/Include/CrtLibSupport.h
6009e6
+++ b/CryptoPkg/Library/Include/CrtLibSupport.h
6009e6
@@ -74,6 +74,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
6009e6
 // Definitions for global constants used by CRT library routines
6009e6
 //
6009e6
 #define EINVAL       22               /* Invalid argument */
6009e6
+#define EAFNOSUPPORT 47               /* Address family not supported by protocol family */
6009e6
 #define INT_MAX      0x7FFFFFFF       /* Maximum (signed) int value */
6009e6
 #define LONG_MAX     0X7FFFFFFFL      /* max value for a long */
6009e6
 #define LONG_MIN     (-LONG_MAX-1)    /* min value for a long */
6009e6
@@ -81,13 +82,28 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
6009e6
 #define CHAR_BIT     8                /* Number of bits in a char */
6009e6
 
6009e6
 //
6009e6
+// Address families.
6009e6
+//
6009e6
+#define AF_INET   2     /* internetwork: UDP, TCP, etc. */
6009e6
+#define AF_INET6  24    /* IP version 6 */
6009e6
+
6009e6
+//
6009e6
+// Define constants based on RFC0883, RFC1034, RFC 1035
6009e6
+//
6009e6
+#define NS_INT16SZ    2   /*%< #/bytes of data in a u_int16_t */
6009e6
+#define NS_INADDRSZ   4   /*%< IPv4 T_A */
6009e6
+#define NS_IN6ADDRSZ  16  /*%< IPv6 T_AAAA */
6009e6
+
6009e6
+//
6009e6
 // Basic types mapping
6009e6
 //
6009e6
 typedef UINTN          size_t;
6009e6
+typedef UINTN          u_int;
6009e6
 typedef INTN           ssize_t;
6009e6
 typedef INT32          time_t;
6009e6
 typedef UINT8          __uint8_t;
6009e6
 typedef UINT8          sa_family_t;
6009e6
+typedef UINT8          u_char;
6009e6
 typedef UINT32         uid_t;
6009e6
 typedef UINT32         gid_t;
6009e6
 
6009e6
diff --git a/CryptoPkg/Library/Include/arpa/inet.h b/CryptoPkg/Library/Include/arpa/inet.h
6009e6
new file mode 100644
6009e6
index 0000000..988e4e0
6009e6
--- /dev/null
6009e6
+++ b/CryptoPkg/Library/Include/arpa/inet.h
6009e6
@@ -0,0 +1,9 @@
6009e6
+/** @file
6009e6
+  Include file to support building third-party standard C / BSD sockets code.
6009e6
+
6009e6
+  Copyright (C) 2019, Red Hat, Inc.
6009e6
+
6009e6
+  SPDX-License-Identifier: BSD-2-Clause-Patent
6009e6
+**/
6009e6
+
6009e6
+#include <CrtLibSupport.h>
6009e6
diff --git a/CryptoPkg/Library/Include/arpa/nameser.h b/CryptoPkg/Library/Include/arpa/nameser.h
6009e6
new file mode 100644
6009e6
index 0000000..988e4e0
6009e6
--- /dev/null
6009e6
+++ b/CryptoPkg/Library/Include/arpa/nameser.h
6009e6
@@ -0,0 +1,9 @@
6009e6
+/** @file
6009e6
+  Include file to support building third-party standard C / BSD sockets code.
6009e6
+
6009e6
+  Copyright (C) 2019, Red Hat, Inc.
6009e6
+
6009e6
+  SPDX-License-Identifier: BSD-2-Clause-Patent
6009e6
+**/
6009e6
+
6009e6
+#include <CrtLibSupport.h>
6009e6
diff --git a/CryptoPkg/Library/Include/netinet/in.h b/CryptoPkg/Library/Include/netinet/in.h
6009e6
new file mode 100644
6009e6
index 0000000..988e4e0
6009e6
--- /dev/null
6009e6
+++ b/CryptoPkg/Library/Include/netinet/in.h
6009e6
@@ -0,0 +1,9 @@
6009e6
+/** @file
6009e6
+  Include file to support building third-party standard C / BSD sockets code.
6009e6
+
6009e6
+  Copyright (C) 2019, Red Hat, Inc.
6009e6
+
6009e6
+  SPDX-License-Identifier: BSD-2-Clause-Patent
6009e6
+**/
6009e6
+
6009e6
+#include <CrtLibSupport.h>
6009e6
diff --git a/CryptoPkg/Library/Include/sys/param.h b/CryptoPkg/Library/Include/sys/param.h
6009e6
new file mode 100644
6009e6
index 0000000..988e4e0
6009e6
--- /dev/null
6009e6
+++ b/CryptoPkg/Library/Include/sys/param.h
6009e6
@@ -0,0 +1,9 @@
6009e6
+/** @file
6009e6
+  Include file to support building third-party standard C / BSD sockets code.
6009e6
+
6009e6
+  Copyright (C) 2019, Red Hat, Inc.
6009e6
+
6009e6
+  SPDX-License-Identifier: BSD-2-Clause-Patent
6009e6
+**/
6009e6
+
6009e6
+#include <CrtLibSupport.h>
6009e6
diff --git a/CryptoPkg/Library/Include/sys/socket.h b/CryptoPkg/Library/Include/sys/socket.h
6009e6
new file mode 100644
6009e6
index 0000000..988e4e0
6009e6
--- /dev/null
6009e6
+++ b/CryptoPkg/Library/Include/sys/socket.h
6009e6
@@ -0,0 +1,9 @@
6009e6
+/** @file
6009e6
+  Include file to support building third-party standard C / BSD sockets code.
6009e6
+
6009e6
+  Copyright (C) 2019, Red Hat, Inc.
6009e6
+
6009e6
+  SPDX-License-Identifier: BSD-2-Clause-Patent
6009e6
+**/
6009e6
+
6009e6
+#include <CrtLibSupport.h>
6009e6
-- 
6009e6
1.8.3.1
6009e6