render / rpms / edk2

Forked from rpms/edk2 2 months ago
Clone

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

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