No public description

PiperOrigin-RevId: 603532080
Change-Id: Idde94fadf961c63dcda96921efeed324571c3d42
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/ChangeLog b/google3/third_party/grte/v5_src/glibc-2.27/ChangeLog
index c9ab984..0306f0c 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/ChangeLog
+++ b/google3/third_party/grte/v5_src/glibc-2.27/ChangeLog
@@ -1,3 +1,43 @@
+2019-01-21  Florian Weimer  <fweimer@redhat.com>
+
+	[BZ #20018]
+	CVE-2016-10739
+	resolv: Reject trailing characters in host names
+	* include/arpa/inet.h (__inet_aton_exact): Declare.
+	(inet_aton): Remove hidden prototype.  No longer used internally.
+	* nscd/gai.c (__inet_aton): Do not define.
+	* nscd/gethstbynm3_r.c (__inet_aton): Likewise.
+	* nss/digits_dots.c (__inet_aton): Likewise.
+	(__nss_hostname_digits_dots_context): Call __inet_aton_exact.
+	* resolv/Makefile (tests-internal): Add tst-inet_aton_exact.
+	(tests): Add tst-resolv-nondecimal, tst-resolv-trailing.
+	(tst-resolv-nondecimal): Link with libresolv.so and libpthread.
+	(tst-resolv-trailing): Likewise.
+	* resolv/Versions (GLIBC_PRIVATE): Export __inet_aton_exact from
+	libc.
+	* resolv/inet_addr.c (inet_aton_end): Remame from __inet_aton.
+	Make static.  Add endp parameter.
+	(__inet_aton_exact): New function.
+	(__inet_aton_ignore_trailing): New function, aliased to inet_aton.
+	(__inet_addr): Call inet_aton_end.
+	* resolv/res_init.c (res_vinit_1): Truncate nameserver for IPv4,
+	not just IPv6.  Call __inet_aton_exact.
+	* resolv/tst-aton.c: Switch to <support/test-driver.c>.
+	(tests): Make const.  Add additional test cases with trailing
+	characters.
+	(do_test): Use array_length.
+	* resolv/tst-inet_aton_exact.c: New file.
+	* resolv/tst-resolv-trailing.c: Likewise.
+	* resolv/tst-resolv-nondecimal.c: Likewise.
+	* sysdeps/posix/getaddrinfo.c (gaih_inet): Call __inet_aton_exact.
+
+2018-11-27  Florian Weimer  <fweimer@redhat.com>
+
+	[BZ #23927]
+	CVE-2018-19591
+	* sysdeps/unix/sysv/linux/if_index.c (__if_nametoindex): Avoid
+	descriptor leak in case of ENODEV error.
+
 2018-05-18  Joseph Myers  <joseph@codesourcery.com>
 
 	[BZ #22639]
@@ -5,6 +45,7 @@
 	* time/tst-y2039.c: New file.
 	* time/Makefile (tests): Add tst-y2039.
 
+
 2018-02-12  Zack Weinberg  <zackw@panix.com>
 
 	[BZ #19239]
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/Makeconfig b/google3/third_party/grte/v5_src/glibc-2.27/Makeconfig
index fea770f..021636b 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/Makeconfig
+++ b/google3/third_party/grte/v5_src/glibc-2.27/Makeconfig
@@ -936,6 +936,7 @@
 LDFLAGS.so += -fuse-ld=lld
 LDFLAGS-rtld += -fuse-ld=lld
 LDFLAGS += -fuse-ld=lld
+LDFLAGS += -Wl,--undefined-version
 endif
 
 endif	# with-clang == yes
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/NEWS b/google3/third_party/grte/v5_src/glibc-2.27/NEWS
index 4be0b98..e093778 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/NEWS
+++ b/google3/third_party/grte/v5_src/glibc-2.27/NEWS
@@ -28,6 +28,20 @@
 
 Security related changes:
 
+  CVE-2021-3999: Passing a buffer of size exactly 1 byte to the getcwd
+  function may result in an off-by-one buffer underflow and overflow
+  when the current working directory is longer than PATH_MAX and also
+  corresponds to the / directory through an unprivileged mount
+  namespace.  Reported by Qualys.
+
+  CVE-2016-10739: The getaddrinfo function could successfully parse IPv4
+  addresses with arbitrary trailing characters, potentially leading to data
+  or command injection issues in applications.
+
+  CVE-2018-19591: A file descriptor leak in if_nametoindex can lead to a
+  denial of service due to resource exhaustion when processing getaddrinfo
+  calls with crafted host names.  Reported by Guido Vranken.
+
   CVE-2017-18269: An SSE2-based memmove implementation for the i386
   architecture could corrupt memory.  Reported by Max Horn.
 
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/assert/assert.h b/google3/third_party/grte/v5_src/glibc-2.27/assert/assert.h
index 5468c16..f48401c 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/assert/assert.h
+++ b/google3/third_party/grte/v5_src/glibc-2.27/assert/assert.h
@@ -86,10 +86,21 @@
    parentheses around EXPR.  Otherwise, those added parentheses would
    suppress warnings we'd expect to be detected by gcc's -Wparentheses.  */
 # if defined __cplusplus
+#  if defined __has_builtin
+#   if __has_builtin (__builtin_FILE)
+#    define __ASSERT_FILE __builtin_FILE ()
+#    define __ASSERT_LINE __builtin_LINE ()
+#   endif
+#  endif
+#  if !defined __ASSERT_FILE
+#   define __ASSERT_FILE __FILE__
+#   define __ASSERT_LINE __LINE__
+#  endif
 #  define assert(expr)							\
      (static_cast <bool> (expr)						\
       ? void (0)							\
-      : __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION))
+      : __assert_fail (#expr, __ASSERT_FILE, __ASSERT_LINE,             \
+                       __ASSERT_FUNCTION))
 # elif !defined __GNUC__ || defined __STRICT_ANSI__
 #  define assert(expr)							\
     ((expr)								\
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/configure b/google3/third_party/grte/v5_src/glibc-2.27/configure
index 447318e..4f7b42a 100755
--- a/google3/third_party/grte/v5_src/glibc-2.27/configure
+++ b/google3/third_party/grte/v5_src/glibc-2.27/configure
@@ -5379,17 +5379,10 @@
 if test -n "$CXX"; then
   # In theory the clang and gcc regexes can be merged, but the
   # result is incomprehensible.
-  if test "$with_clang" != no; then
-  find_cxx_header () {
-    echo "#include <$1>" | $CXX -M -MP -x c++ - 2>/dev/null \
-	 | sed -n "\,^[o.-]*[ :] /.*/$1 [\]$,{s,^[o.-]*[ :] /,/,;s/ [\]$//;p}"
-  }
-  else
   find_cxx_header () {
     echo "#include <$1>" | $CXX -M -MP -x c++ - 2>/dev/null \
 	 | sed -n "\,$1:,{s/:\$//;p}"
   }
-  fi
   CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)"
   CXX_CMATH_HEADER="$(find_cxx_header cmath)"
   CXX_BITS_STD_ABS_H="$(find_cxx_header bits/std_abs.h)"
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/configure.ac b/google3/third_party/grte/v5_src/glibc-2.27/configure.ac
index b1a1530..c0638a1 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/configure.ac
+++ b/google3/third_party/grte/v5_src/glibc-2.27/configure.ac
@@ -1088,17 +1088,10 @@
 if test -n "$CXX"; then
   # In theory the clang and gcc regexes can be merged, but the
   # result is incomprehensible.
-  if test "$with_clang" != no; then
-  find_cxx_header () {
-    echo "#include <$1>" | $CXX -M -MP -x c++ - 2>/dev/null \
-	 | sed -n "\,^[o.-]*[ :] /.*/$1 [\]$,{s,^[o.-]*[ :] /,/,;s/ [\]$//;p}"
-  }
-  else
   find_cxx_header () {
     echo "#include <$1>" | $CXX -M -MP -x c++ - 2>/dev/null \
 	 | sed -n "\,$1:,{s/:\$//;p}"
   }
-  fi
   CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)"
   CXX_CMATH_HEADER="$(find_cxx_header cmath)"
   CXX_BITS_STD_ABS_H="$(find_cxx_header bits/std_abs.h)"
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/include/arpa/inet.h b/google3/third_party/grte/v5_src/glibc-2.27/include/arpa/inet.h
index c3f28f2..19aec74 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/include/arpa/inet.h
+++ b/google3/third_party/grte/v5_src/glibc-2.27/include/arpa/inet.h
@@ -1,10 +1,10 @@
 #include <inet/arpa/inet.h>
 
 #ifndef _ISOMAC
-extern int __inet_aton (const char *__cp, struct in_addr *__inp);
-libc_hidden_proto (__inet_aton)
+/* Variant of inet_aton which rejects trailing garbage.  */
+extern int __inet_aton_exact (const char *__cp, struct in_addr *__inp);
+libc_hidden_proto (__inet_aton_exact)
 
-libc_hidden_proto (inet_aton)
 libc_hidden_proto (inet_ntop)
 libc_hidden_proto (inet_pton)
 extern __typeof (inet_pton) __inet_pton;
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/nptl/allocatestack.c b/google3/third_party/grte/v5_src/glibc-2.27/nptl/allocatestack.c
index 9f6a756..1989ca7 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/nptl/allocatestack.c
+++ b/google3/third_party/grte/v5_src/glibc-2.27/nptl/allocatestack.c
@@ -276,7 +276,7 @@
 
 	  /* Remove this block.  This should never fail.  If it does
 	     something is really wrong.  */
-	  if (__munmap (curr->stackblock, curr->stackblock_size) != 0)
+	  if (munmap (curr->stackblock, curr->stackblock_size) != 0)
 	    abort ();
 
 	  /* Maybe we have freed enough.  */
@@ -558,7 +558,7 @@
 	  /* If a guard page is required, avoid committing memory by first
 	     allocate with PROT_NONE and then reserve with required permission
 	     excluding the guard page.  */
-	  mem = __mmap (NULL, size, (guardsize == 0) ? prot : PROT_NONE,
+	  mem = mmap (NULL, size, (guardsize == 0) ? prot : PROT_NONE,
 			MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, -1, 0);
 
 	  if (__glibc_unlikely (mem == MAP_FAILED))
@@ -585,7 +585,7 @@
 					    pagesize_m1);
 	      if (setup_stack_prot (mem, size, guard, guardsize, prot) != 0)
 		{
-		  __munmap (mem, size);
+		  munmap (mem, size);
 		  return errno;
 		}
 	    }
@@ -628,7 +628,7 @@
 	      assert (errno == ENOMEM);
 
 	      /* Free the stack memory we just allocated.  */
-	      (void) __munmap (mem, size);
+	      (void) munmap (mem, size);
 
 	      return errno;
 	    }
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/nptl/pthread_cond_wait.c b/google3/third_party/grte/v5_src/glibc-2.27/nptl/pthread_cond_wait.c
index 3e11054..0dbab42 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/nptl/pthread_cond_wait.c
+++ b/google3/third_party/grte/v5_src/glibc-2.27/nptl/pthread_cond_wait.c
@@ -510,34 +510,13 @@
 	      if (__glibc_unlikely (abstime->tv_sec < 0))
 	        err = ETIMEDOUT;
 
-	      else if ((flags & __PTHREAD_COND_CLOCK_MONOTONIC_MASK) != 0)
-		{
-		  /* CLOCK_MONOTONIC is requested.  */
-		  struct timespec rt;
-		  if (__clock_gettime (CLOCK_MONOTONIC, &rt) != 0)
-		    __libc_fatal ("clock_gettime does not support "
-				  "CLOCK_MONOTONIC");
-		  /* Convert the absolute timeout value to a relative
-		     timeout.  */
-		  rt.tv_sec = abstime->tv_sec - rt.tv_sec;
-		  rt.tv_nsec = abstime->tv_nsec - rt.tv_nsec;
-		  if (rt.tv_nsec < 0)
-		    {
-		      rt.tv_nsec += 1000000000;
-		      --rt.tv_sec;
-		    }
-		  /* Did we already time out?  */
-		  if (__glibc_unlikely (rt.tv_sec < 0))
-		    err = ETIMEDOUT;
-		  else
-		    err = futex_reltimed_wait_cancelable
-			(cond->__data.__g_signals + g, 0, &rt, private);
-		}
 	      else
 		{
-		  /* Use CLOCK_REALTIME.  */
 		  err = futex_abstimed_wait_cancelable
-		      (cond->__data.__g_signals + g, 0, abstime, private);
+		      (cond->__data.__g_signals + g, 0, abstime,
+		      (flags & __PTHREAD_COND_CLOCK_MONOTONIC_MASK) != 0
+                        ? 0
+                        : FUTEX_CLOCK_REALTIME, private);
 		}
 	    }
 
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/nptl/sem_waitcommon.c b/google3/third_party/grte/v5_src/glibc-2.27/nptl/sem_waitcommon.c
index 30984be..7d2a5b2 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/nptl/sem_waitcommon.c
+++ b/google3/third_party/grte/v5_src/glibc-2.27/nptl/sem_waitcommon.c
@@ -110,10 +110,10 @@
 #if __HAVE_64B_ATOMICS
   err = futex_abstimed_wait_cancelable (
       (unsigned int *) &sem->data + SEM_VALUE_OFFSET, 0, abstime,
-      sem->private);
+      FUTEX_CLOCK_REALTIME, sem->private);
 #else
   err = futex_abstimed_wait_cancelable (&sem->value, SEM_NWAITERS_MASK,
-					abstime, sem->private);
+					abstime, FUTEX_CLOCK_REALTIME, sem->private);
 #endif
 
   return err;
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/nptl/tst-thread_local1.cc b/google3/third_party/grte/v5_src/glibc-2.27/nptl/tst-thread_local1.cc
index 0cfdcd6..5f4cf5c 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/nptl/tst-thread_local1.cc
+++ b/google3/third_party/grte/v5_src/glibc-2.27/nptl/tst-thread_local1.cc
@@ -21,6 +21,7 @@
 #include <stdio.h>
 #include <string.h>
 
+#include <array>
 #include <functional>
 #include <string>
 #include <thread>
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/nscd/gai.c b/google3/third_party/grte/v5_src/glibc-2.27/nscd/gai.c
index 576fd00..671169a 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/nscd/gai.c
+++ b/google3/third_party/grte/v5_src/glibc-2.27/nscd/gai.c
@@ -19,7 +19,6 @@
 
 /* This file uses the getaddrinfo code but it compiles it without NSCD
    support.  We just need a few symbol renames.  */
-#define __inet_aton inet_aton
 #define __ioctl ioctl
 #define __getsockname getsockname
 #define __socket socket
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/nscd/gethstbynm3_r.c b/google3/third_party/grte/v5_src/glibc-2.27/nscd/gethstbynm3_r.c
index 7beb9dc..f792c4f 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/nscd/gethstbynm3_r.c
+++ b/google3/third_party/grte/v5_src/glibc-2.27/nscd/gethstbynm3_r.c
@@ -38,8 +38,6 @@
 #define HAVE_LOOKUP_BUFFER	1
 #define HAVE_AF			1
 
-#define __inet_aton inet_aton
-
 /* We are nscd, so we don't want to be talking to ourselves.  */
 #undef	USE_NSCD
 
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/nss/digits_dots.c b/google3/third_party/grte/v5_src/glibc-2.27/nss/digits_dots.c
index 39bff38..5441bce 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/nss/digits_dots.c
+++ b/google3/third_party/grte/v5_src/glibc-2.27/nss/digits_dots.c
@@ -29,7 +29,6 @@
 #include "nsswitch.h"
 
 #ifdef USE_NSCD
-# define inet_aton __inet_aton
 # include <nscd/nscd_proto.h>
 #endif
 
@@ -160,7 +159,7 @@
 		     255.255.255.255?  The test below will succeed
 		     spuriously... ???  */
 		  if (af == AF_INET)
-		    ok = __inet_aton (name, (struct in_addr *) host_addr);
+		    ok = __inet_aton_exact (name, (struct in_addr *) host_addr);
 		  else
 		    {
 		      assert (af == AF_INET6);
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/nss/nss_borg/borg-pwd.c b/google3/third_party/grte/v5_src/glibc-2.27/nss/nss_borg/borg-pwd.c
index 2e50b28..b3c18e0 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/nss/nss_borg/borg-pwd.c
+++ b/google3/third_party/grte/v5_src/glibc-2.27/nss/nss_borg/borg-pwd.c
@@ -9,6 +9,7 @@
 #include <string.h>
 #include <sys/types.h>
 #include <syslog.h>
+#include <unistd.h>
 
 #include <libc-lock.h>
 __libc_lock_define_initialized(static, lock)
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/resolv/Versions b/google3/third_party/grte/v5_src/glibc-2.27/resolv/Versions
index b05778d..9a82704 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/resolv/Versions
+++ b/google3/third_party/grte/v5_src/glibc-2.27/resolv/Versions
@@ -27,6 +27,7 @@
     __h_errno; __resp;
 
     __res_iclose;
+    __inet_aton_exact;
     __inet_pton_length;
     __resolv_context_get;
     __resolv_context_get_preinit;
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/resolv/inet_addr.c b/google3/third_party/grte/v5_src/glibc-2.27/resolv/inet_addr.c
index 022f7ea..d5f228d 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/resolv/inet_addr.c
+++ b/google3/third_party/grte/v5_src/glibc-2.27/resolv/inet_addr.c
@@ -78,29 +78,14 @@
 #include <limits.h>
 #include <errno.h>
 
-/*
- * Ascii internet address interpretation routine.
- * The value returned is in network order.
- */
-in_addr_t
-__inet_addr(const char *cp) {
-	struct in_addr val;
-
-	if (__inet_aton(cp, &val))
-		return (val.s_addr);
-	return (INADDR_NONE);
-}
-weak_alias (__inet_addr, inet_addr)
-
-/*
- * Check whether "cp" is a valid ascii representation
- * of an Internet address and convert to a binary address.
- * Returns 1 if the address is valid, 0 if not.
- * This replaces inet_addr, the return value from which
- * cannot distinguish between failure and a local broadcast address.
- */
-int
-__inet_aton(const char *cp, struct in_addr *addr)
+/* Check whether "cp" is a valid ASCII representation of an IPv4
+   Internet address and convert it to a binary address.  Returns 1 if
+   the address is valid, 0 if not.  This replaces inet_addr, the
+   return value from which cannot distinguish between failure and a
+   local broadcast address.  Write a pointer to the first
+   non-converted character to *endp.  */
+static int
+inet_aton_end (const char *cp, struct in_addr *addr, const char **endp)
 {
 	static const in_addr_t max[4] = { 0xffffffff, 0xffffff, 0xffff, 0xff };
 	in_addr_t val;
@@ -170,6 +155,7 @@
 
 	if (addr != NULL)
 		addr->s_addr = res.word | htonl (val);
+	*endp = cp;
 
 	__set_errno (saved_errno);
 	return (1);
@@ -178,6 +164,41 @@
 	__set_errno (saved_errno);
 	return (0);
 }
-weak_alias (__inet_aton, inet_aton)
-libc_hidden_def (__inet_aton)
-libc_hidden_weak (inet_aton)
+
+int
+__inet_aton_exact (const char *cp, struct in_addr *addr)
+{
+  struct in_addr val;
+  const char *endp;
+  /* Check that inet_aton_end parsed the entire string.  */
+  if (inet_aton_end (cp, &val, &endp) != 0 && *endp == 0)
+    {
+      *addr = val;
+      return 1;
+    }
+  else
+    return 0;
+}
+libc_hidden_def (__inet_aton_exact)
+
+/* inet_aton ignores trailing garbage.  */
+int
+__inet_aton_ignore_trailing (const char *cp, struct in_addr *addr)
+{
+  const char *endp;
+  return  inet_aton_end (cp, addr, &endp);
+}
+weak_alias (__inet_aton_ignore_trailing, inet_aton)
+
+/* ASCII IPv4 Internet address interpretation routine.  The value
+   returned is in network order.  */
+in_addr_t
+__inet_addr (const char *cp)
+{
+  struct in_addr val;
+  const char *endp;
+  if (inet_aton_end (cp, &val, &endp))
+    return val.s_addr;
+  return INADDR_NONE;
+}
+weak_alias (__inet_addr, inet_addr)
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/resolv/res_init.c b/google3/third_party/grte/v5_src/glibc-2.27/resolv/res_init.c
index f5e52cb..94743a2 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/resolv/res_init.c
+++ b/google3/third_party/grte/v5_src/glibc-2.27/resolv/res_init.c
@@ -399,8 +399,16 @@
               cp = parser->buffer + sizeof ("nameserver") - 1;
               while (*cp == ' ' || *cp == '\t')
                 cp++;
+
+              /* Ignore trailing contents on the name server line.  */
+              {
+                char *el;
+                if ((el = strpbrk (cp, " \t\n")) != NULL)
+                  *el = '\0';
+              }
+
               struct sockaddr *sa;
-              if ((*cp != '\0') && (*cp != '\n') && __inet_aton (cp, &a))
+              if ((*cp != '\0') && (*cp != '\n') && __inet_aton_exact (cp, &a))
                 {
                   sa = allocate_address_v4 (a, NAMESERVER_PORT);
                   if (sa == NULL)
@@ -410,9 +418,6 @@
                 {
                   struct in6_addr a6;
                   char *el;
-
-                  if ((el = strpbrk (cp, " \t\n")) != NULL)
-                    *el = '\0';
                   if ((el = strchr (cp, SCOPE_DELIMITER)) != NULL)
                     *el = '\0';
                   if ((*cp != '\0') && (__inet_pton (AF_INET6, cp, &a6) > 0))
@@ -472,7 +477,7 @@
                   char separator = *cp;
                   *cp = 0;
                   struct resolv_sortlist_entry e;
-                  if (__inet_aton (net, &a))
+                  if (__inet_aton_exact (net, &a))
                     {
                       e.addr = a;
                       if (is_sort_mask (separator))
@@ -484,7 +489,7 @@
                             cp++;
                           separator = *cp;
                           *cp = 0;
-                          if (__inet_aton (net, &a))
+                          if (__inet_aton_exact (net, &a))
                             e.mask = a.s_addr;
                           else
                             e.mask = net_mask (e.addr);
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/resolv/tst-aton.c b/google3/third_party/grte/v5_src/glibc-2.27/resolv/tst-aton.c
index 08110a0..eb734d7 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/resolv/tst-aton.c
+++ b/google3/third_party/grte/v5_src/glibc-2.27/resolv/tst-aton.c
@@ -1,11 +1,29 @@
+/* Test legacy IPv4 text-to-address function inet_aton.
+   Copyright (C) 1998-2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <array_length.h>
 #include <stdio.h>
 #include <stdint.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
-
-static struct tests
+static const struct tests
 {
   const char *input;
   int valid;
@@ -16,6 +34,7 @@
   { "-1", 0, 0 },
   { "256", 1, 0x00000100 },
   { "256.", 0, 0 },
+  { "255a", 0, 0 },
   { "256a", 0, 0 },
   { "0x100", 1, 0x00000100 },
   { "0200.0x123456", 1, 0x80123456 },
@@ -40,7 +59,12 @@
   { "1.2.256.4", 0, 0 },
   { "1.2.3.0x100", 0, 0 },
   { "323543357756889", 0, 0 },
-  { "10.1.2.3.4", 0, 0},
+  { "10.1.2.3.4", 0, 0 },
+  { "192.0.2.1", 1, 0xc0000201 },
+  { "192.0.2.2\nX", 1, 0xc0000202 },
+  { "192.0.2.3 Y", 1, 0xc0000203 },
+  { "192.0.2.3Z", 0, 0 },
+  { "192.000.002.010", 1, 0xc0000208 },
 };
 
 
@@ -50,7 +74,7 @@
   int result = 0;
   size_t cnt;
 
-  for (cnt = 0; cnt < sizeof (tests) / sizeof (tests[0]); ++cnt)
+  for (cnt = 0; cnt < array_length (tests); ++cnt)
     {
       struct in_addr addr;
 
@@ -73,5 +97,4 @@
   return result;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/resolv/tst-inet_aton_exact.c b/google3/third_party/grte/v5_src/glibc-2.27/resolv/tst-inet_aton_exact.c
new file mode 100644
index 0000000..0fdfa3d
--- /dev/null
+++ b/google3/third_party/grte/v5_src/glibc-2.27/resolv/tst-inet_aton_exact.c
@@ -0,0 +1,47 @@
+/* Test internal legacy IPv4 text-to-address function __inet_aton_exact.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <arpa/inet.h>
+#include <support/check.h>
+
+static int
+do_test (void)
+{
+  struct in_addr addr = { };
+
+  TEST_COMPARE (__inet_aton_exact ("192.0.2.1", &addr), 1);
+  TEST_COMPARE (ntohl (addr.s_addr), 0xC0000201);
+
+  TEST_COMPARE (__inet_aton_exact ("192.000.002.010", &addr), 1);
+  TEST_COMPARE (ntohl (addr.s_addr), 0xC0000208);
+  TEST_COMPARE (__inet_aton_exact ("0xC0000234", &addr), 1);
+  TEST_COMPARE (ntohl (addr.s_addr), 0xC0000234);
+
+  /* Trailing content is not accepted.  */
+  TEST_COMPARE (__inet_aton_exact ("192.0.2.2X", &addr), 0);
+  TEST_COMPARE (__inet_aton_exact ("192.0.2.3 Y", &addr), 0);
+  TEST_COMPARE (__inet_aton_exact ("192.0.2.4\nZ", &addr), 0);
+  TEST_COMPARE (__inet_aton_exact ("192.0.2.5\tT", &addr), 0);
+  TEST_COMPARE (__inet_aton_exact ("192.0.2.6 Y", &addr), 0);
+  TEST_COMPARE (__inet_aton_exact ("192.0.2.7\n", &addr), 0);
+  TEST_COMPARE (__inet_aton_exact ("192.0.2.8\t", &addr), 0);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/generic/math_private.h b/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/generic/math_private.h
index e4b9d86..d5b900a 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/generic/math_private.h
+++ b/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/generic/math_private.h
@@ -227,7 +227,7 @@
 #if __HAVE_DISTINCT_FLOAT128
 
 /* __builtin_isinf_sign is broken in GCC < 7 for float128.  */
-# if ! __GNUC_PREREQ (7, 0)
+# if ! __GNUC_PREREQ (7, 0) || defined(__clang__)
 #  include <ieee754_float128.h>
 extern inline int
 __isinff128 (_Float128 x)
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/ieee754/float128/Makefile b/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/ieee754/float128/Makefile
index 70bb3ac..2b73684 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/ieee754/float128/Makefile
+++ b/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/ieee754/float128/Makefile
@@ -11,4 +11,131 @@
 ifeq ($(subdir),wcsmbs)
 routines += wcstof128_l wcstof128 wcstof128_nan
 endif
+
+ifeq ($(subdir),math)
+CFLAGS-w_acosf128.c += -fno-builtin-acosf64x
+CFLAGS-w_acoshf128.c += -fno-builtin-acoshf64x
+CFLAGS-w_asinf128.c += -fno-builtin-asinf64x
+CFLAGS-s_asinhf128.c += -fno-builtin-asinhf64x
+CFLAGS-s_atanf128.c += -fno-builtin-atanf64x
+CFLAGS-w_atan2f128.c += -fno-builtin-atan2f64x
+CFLAGS-w_atanhf128.c += -fno-builtin-atanhf64x
+CFLAGS-s_cabsf128.c += -fno-builtin-cabsf64x
+CFLAGS-s_cacosf128.c += -fno-builtin-cacosf64x
+CFLAGS-s_cacoshf128.c += -fno-builtin-cacoshf64x
+CFLAGS-s_canonicalizef128.c += -fno-builtin-canonicalizef64x
+CFLAGS-s_cargf128.c += -fno-builtin-cargf64x
+CFLAGS-s_casinf128.c += -fno-builtin-casinf64x
+CFLAGS-s_casinhf128.c += -fno-builtin-casinhf64x
+CFLAGS-s_catanf128.c += -fno-builtin-catanf64x
+CFLAGS-s_catanhf128.c += -fno-builtin-catanhf64x
+CFLAGS-s_cbrtf128.c += -fno-builtin-cbrtf64x
+CFLAGS-s_ccosf128.c += -fno-builtin-ccosf64x
+CFLAGS-s_ccoshf128.c += -fno-builtin-ccoshf64x
+CFLAGS-s_ceilf128.c += -fno-builtin-ceilf64x
+CFLAGS-s_cexpf128.c += -fno-builtin-cexpf64x
+CFLAGS-s_cimagf128.c += -fno-builtin-cimagf64x
+CFLAGS-s_clogf128.c += -fno-builtin-clogf64x
+CFLAGS-s_clog10f128.c += -fno-builtin-clog10f64x
+CFLAGS-s_conjf128.c += -fno-builtin-conjf64x
+CFLAGS-s_copysignf128.c += -fno-builtin-copysignf64x
+CFLAGS-s_cosf128.c += -fno-builtin-cosf64x
+CFLAGS-w_coshf128.c += -fno-builtin-coshf64x
+CFLAGS-s_cpowf128.c += -fno-builtin-cpowf64x
+CFLAGS-s_cprojf128.c += -fno-builtin-cprojf64x
+CFLAGS-s_crealf128.c += -fno-builtin-crealf64x
+CFLAGS-s_csinf128.c += -fno-builtin-csinf64x
+CFLAGS-s_csinhf128.c += -fno-builtin-csinhf64x
+CFLAGS-s_csqrtf128.c += -fno-builtin-csqrtf64x
+CFLAGS-s_ctanf128.c += -fno-builtin-ctanf64x
+CFLAGS-s_ctanhf128.c += -fno-builtin-ctanhf64x
+CFLAGS-s_daddf128.c += -fno-builtin-f64addf64x
+CFLAGS-s_ddivf128.c += -fno-builtin-f64divf64x
+CFLAGS-s_dfmaf128.c += -fno-builtin-f64fmaf64x
+CFLAGS-s_dmulf128.c += -fno-builtin-f64mulf64x
+CFLAGS-s_dsqrtf128.c += -fno-builtin-f64sqrtf64x
+CFLAGS-s_dsubf128.c += -fno-builtin-f64subf64x
+CFLAGS-s_erff128.c += -fno-builtin-erff64x
+CFLAGS-s_erfcf128.c += -fno-builtin-erfcf64x
+CFLAGS-e_expf128.c += -fno-builtin-expf64x
+CFLAGS-w_exp10f128.c += -fno-builtin-exp10f64x
+CFLAGS-e_exp2f128.c += -fno-builtin-exp2f64x
+CFLAGS-s_expm1f128.c += -fno-builtin-expm1f64x
+CFLAGS-s_fabsf128.c += -fno-builtin-fabsf64x
+CFLAGS-s_faddf128.c += -fno-builtin-f32addf64x
+CFLAGS-s_fdimf128.c += -fno-builtin-fdimf64x
+CFLAGS-s_fdivf128.c += -fno-builtin-f32divf64x
+CFLAGS-s_ffmaf128.c += -fno-builtin-f32fmaf64x
+CFLAGS-s_floorf128.c += -fno-builtin-floorf64x
+CFLAGS-s_fmaf128.c += -fno-builtin-fmaf64x
+CFLAGS-s_fmaxf128.c += -fno-builtin-fmaxf64x
+CFLAGS-s_fmaximumf128.c += -fno-builtin-fmaximumf64x
+CFLAGS-s_fmaximum_magf128.c += -fno-builtin-fmaximum_magf64x
+CFLAGS-s_fmaximum_mag_numf128.c += -fno-builtin-fmaximum_mag_numf64x
+CFLAGS-s_fmaximum_numf128.c += -fno-builtin-fmaximum_numf64x
+CFLAGS-s_fmaxmagf128.c += -fno-builtin-fmaxmagf64x
+CFLAGS-s_fminf128.c += -fno-builtin-fminf64x
+CFLAGS-s_fminimumf128.c += -fno-builtin-fminimumf64x
+CFLAGS-s_fminimum_magf128.c += -fno-builtin-fminimum_magf64x
+CFLAGS-s_fminimum_mag_numf128.c += -fno-builtin-fminimum_mag_numf64x
+CFLAGS-s_fminimum_numf128.c += -fno-builtin-fminimum_numf64x
+CFLAGS-s_fminmagf128.c += -fno-builtin-fminmagf64x
+CFLAGS-w_fmodf128.c += -fno-builtin-fmodf64x
+CFLAGS-s_fmulf128.c += -fno-builtin-f32mulf64x
+CFLAGS-s_frexpf128.c += -fno-builtin-frexpf64x
+CFLAGS-s_fromfpf128.c += -fno-builtin-fromfpf64x
+CFLAGS-s_fromfpxf128.c += -fno-builtin-fromfpxf64x
+CFLAGS-s_fsqrtf128.c += -fno-builtin-f32sqrtf64x
+CFLAGS-s_fsubf128.c += -fno-builtin-f32subf64x
+CFLAGS-s_getpayloadf128.c += -fno-builtin-getpayloadf64x
+CFLAGS-w_hypotf128.c += -fno-builtin-hypotf64x
+CFLAGS-w_ilogbf128.c += -fno-builtin-ilogbf64x
+CFLAGS-w_j0f128.c += -fno-builtin-j0f64x
+CFLAGS-w_j1f128.c += -fno-builtin-j1f64x
+CFLAGS-w_jnf128.c += -fno-builtin-jnf64x
+CFLAGS-s_ldexpf128.c += -fno-builtin-ldexpf64x
+CFLAGS-w_lgammaf128.c += -fno-builtin-lgammaf64x
+CFLAGS-w_lgammaf128_r.c += -fno-builtin-lgammaf64x_r
+CFLAGS-w_llogbf128.c += -fno-builtin-llogbf64x
+CFLAGS-s_llrintf128.c += -fno-builtin-llrintf64x
+CFLAGS-s_llroundf128.c += -fno-builtin-llroundf64x
+CFLAGS-e_logf128.c += -fno-builtin-logf64x
+CFLAGS-w_log10f128.c += -fno-builtin-log10f64x
+CFLAGS-w_log1pf128.c += -fno-builtin-log1pf64x
+CFLAGS-e_log2f128.c += -fno-builtin-log2f64x
+CFLAGS-s_logbf128.c += -fno-builtin-logbf64x
+CFLAGS-s_lrintf128.c += -fno-builtin-lrintf64x
+CFLAGS-s_lroundf128.c += -fno-builtin-lroundf64x
+CFLAGS-s_modff128.c += -fno-builtin-modff64x
+CFLAGS-s_nanf128.c += -fno-builtin-nanf64x
+CFLAGS-s_nearbyintf128.c += -fno-builtin-nearbyintf64x
+CFLAGS-s_nextafterf128.c += -fno-builtin-nextafterf64x
+CFLAGS-s_nextdownf128.c += -fno-builtin-nextdownf64x
+CFLAGS-s_nextupf128.c += -fno-builtin-nextupf64x
+CFLAGS-e_powf128.c += -fno-builtin-powf64x
+CFLAGS-w_remainderf128.c += -fno-builtin-remainderf64x
+CFLAGS-s_remquof128.c += -fno-builtin-remquof64x
+CFLAGS-s_rintf128.c += -fno-builtin-rintf64x
+CFLAGS-s_roundf128.c += -fno-builtin-roundf64x
+CFLAGS-s_roundevenf128.c += -fno-builtin-roundevenf64x
+CFLAGS-w_scalblnf128.c += -fno-builtin-scalblnf64x
+CFLAGS-s_scalbnf128.c += -fno-builtin-scalbnf64x
+CFLAGS-s_setpayloadf128.c += -fno-builtin-setpayloadf64x
+CFLAGS-s_setpayloadsigf128.c += -fno-builtin-setpayloadsigf64x
+CFLAGS-s_sinf128.c += -fno-builtin-sinf64x
+CFLAGS-s_sincosf128.c += -fno-builtin-sincosf64x
+CFLAGS-w_sinhf128.c += -fno-builtin-sinhf64x
+CFLAGS-w_sqrtf128.c += -fno-builtin-sqrtf64x
+CFLAGS-s_tanf128.c += -fno-builtin-tanf64x
+CFLAGS-s_tanhf128.c += -fno-builtin-tanhf64x
+CFLAGS-w_tgammaf128.c += -fno-builtin-tgammaf64x
+CFLAGS-s_totalorderf128.c += -fno-builtin-totalorderf64x
+CFLAGS-s_totalordermagf128.c += -fno-builtin-totalordermagf64x
+CFLAGS-s_truncf128.c += -fno-builtin-truncf64x
+CFLAGS-s_ufromfpf128.c += -fno-builtin-ufromfpf64x
+CFLAGS-s_ufromfpxf128.c += -fno-builtin-ufromfpxf64x
+CFLAGS-s_y0f128.c += -fno-builtin-y0f64x
+CFLAGS-s_y1f128.c += -fno-builtin-y1f64x
+CFLAGS-s_ynf128.c += -fno-builtin-ynf64x
+endif
 endif # enable-float128
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/nptl/futex-internal.h b/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/nptl/futex-internal.h
index 1a56247..a0ed961 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/nptl/futex-internal.h
+++ b/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/nptl/futex-internal.h
@@ -169,7 +169,7 @@
 static __always_inline int
 futex_abstimed_wait_cancelable (unsigned int* futex_word,
 				unsigned int expected,
-			        const struct timespec* abstime, int private);
+			        const struct timespec* abstime, int clockbit, int private);
 
 /* Atomically wrt other futex operations on the same futex, this unblocks the
    specified number of processes, or all processes blocked on this futex if
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/posix/getaddrinfo.c b/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/posix/getaddrinfo.c
index c15f76e..27978bc 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/posix/getaddrinfo.c
+++ b/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/posix/getaddrinfo.c
@@ -186,19 +186,16 @@
   return 0;
 }
 
-/* Convert struct hostent to a list of struct gaih_addrtuple objects.
-   h_name is not copied, and the struct hostent object must not be
-   deallocated prematurely.  *RESULT must be NULL or a pointer to a
-   linked-list.  The new addresses are appended at the end.  */
+/* Convert struct hostent to a list of struct gaih_addrtuple objects.  h_name
+   is not copied, and the struct hostent object must not be deallocated
+   prematurely.  The new addresses are appended to the tuple array in
+   RESULT.  */
 static bool
 convert_hostent_to_gaih_addrtuple (const struct addrinfo *req,
 				   int family,
 				   struct hostent *h,
 				   struct gaih_addrtuple **result)
 {
-  while (*result)
-    result = &(*result)->next;
-
   /* Count the number of addresses in h->h_addr_list.  */
   size_t count = 0;
   for (char **p = h->h_addr_list; *p != NULL; ++p)
@@ -209,10 +206,30 @@
   if (count == 0 || h->h_length > sizeof (((struct gaih_addrtuple) {}).addr))
     return true;
 
-  struct gaih_addrtuple *array = calloc (count, sizeof (*array));
+  struct gaih_addrtuple *array = *result;
+  size_t old = 0;
+
+  while (array != NULL)
+    {
+      old++;
+      array = array->next;
+    }
+
+  array = realloc (*result, (old + count) * sizeof (*array));
+
   if (array == NULL)
     return false;
 
+  *result = array;
+
+  /* Update the next pointers on reallocation.  */
+  for (size_t i = 0; i < old; i++)
+    array[i].next = array + i + 1;
+
+  array += old;
+
+  memset (array, 0, count * sizeof (*array));
+
   for (size_t i = 0; i < count; ++i)
     {
       if (family == AF_INET && req->ai_family == AF_INET6)
@@ -232,7 +249,6 @@
   array[0].name = h->h_name;
   array[count - 1].next = NULL;
 
-  *result = array;
   return true;
 }
 
@@ -504,7 +520,7 @@
 	}
 #endif
 
-      if (__inet_aton (name, (struct in_addr *) at->addr) != 0)
+      if (__inet_aton_exact (name, (struct in_addr *) at->addr) != 0)
 	{
 	  if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET)
 	    at->family = AF_INET;
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/posix/getcwd.c b/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/posix/getcwd.c
index b53433a..154b984 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/posix/getcwd.c
+++ b/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/posix/getcwd.c
@@ -241,6 +241,14 @@
   char *path;
 #ifndef NO_ALLOCATION
   size_t allocated = size;
+
+  /* A size of 1 byte is never useful.  */
+  if (allocated == 1)
+    {
+      __set_errno (ERANGE);
+      return NULL;
+    }
+
   if (size == 0)
     {
       if (buf != NULL)
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/sparc/sparc32/sem_waitcommon.c b/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/sparc/sparc32/sem_waitcommon.c
index 1ddd65f..5e45d0c 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/sparc/sparc32/sem_waitcommon.c
+++ b/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/sparc/sparc32/sem_waitcommon.c
@@ -52,7 +52,7 @@
   int err;
 
   err = futex_abstimed_wait_cancelable (&sem->value, SEM_NWAITERS_MASK,
-					abstime, sem->private);
+					abstime, FUTEX_CLOCK_REALTIME, sem->private);
 
   return err;
 }
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/unix/sysv/linux/futex-internal.h b/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/unix/sysv/linux/futex-internal.h
index 96a07b0..7ccd40a 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/unix/sysv/linux/futex-internal.h
+++ b/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/unix/sysv/linux/futex-internal.h
@@ -194,7 +194,7 @@
 static __always_inline int
 futex_abstimed_wait_cancelable (unsigned int *futex_word,
 				unsigned int expected,
-			        const struct timespec *abstime, int private)
+			        const struct timespec *abstime, int clockbit, int private)
 {
   /* Work around the fact that the kernel rejects negative timeout values
      despite them being valid.  */
@@ -203,7 +203,7 @@
   int oldtype;
   oldtype = __pthread_enable_asynccancel ();
   int err = lll_futex_timed_wait_bitset (futex_word, expected, abstime,
-					 FUTEX_CLOCK_REALTIME, private);
+					 clockbit, private);
   __pthread_disable_asynccancel (oldtype);
   switch (err)
     {
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/unix/sysv/linux/if_index.c b/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/unix/sysv/linux/if_index.c
index e3d0898..782fc5e 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/unix/sysv/linux/if_index.c
+++ b/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/unix/sysv/linux/if_index.c
@@ -38,11 +38,6 @@
   return 0;
 #else
   struct ifreq ifr;
-  int fd = __opensock ();
-
-  if (fd < 0)
-    return 0;
-
   if (strlen (ifname) >= IFNAMSIZ)
     {
       __set_errno (ENODEV);
@@ -50,6 +45,12 @@
     }
 
   strncpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
+
+  int fd = __opensock ();
+
+  if (fd < 0)
+    return 0;
+
   if (__ioctl (fd, SIOCGIFINDEX, &ifr) < 0)
     {
       int saved_errno = errno;
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/x86/bits/floatn.h b/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/x86/bits/floatn.h
index ed7bf12..7387bba 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/x86/bits/floatn.h
+++ b/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/x86/bits/floatn.h
@@ -32,7 +32,8 @@
    support, for x86_64 and x86.  */
 #if (defined __x86_64__							\
      ? __GNUC_PREREQ (4, 3)						\
-     : (defined __GNU__ ? __GNUC_PREREQ (4, 5) : __GNUC_PREREQ (4, 4)))
+     : (defined __GNU__ ? __GNUC_PREREQ (4, 5) : __GNUC_PREREQ (4, 4))) \
+    || defined __clang__
 # define __HAVE_FLOAT128 1
 #else
 # define __HAVE_FLOAT128 0
@@ -67,7 +68,8 @@
 /* Defined to concatenate the literal suffix to be used with _Float128
    types, if __HAVE_FLOAT128 is 1. */
 # if __HAVE_FLOAT128
-#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus
+#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus \
+      || defined __clang__
 /* The literal suffix f128 exists only since GCC 7.0.  */
 #   define __f128(x) x##q
 #  else
@@ -77,7 +79,8 @@
 
 /* Defined to a complex binary128 type if __HAVE_FLOAT128 is 1.  */
 # if __HAVE_FLOAT128
-#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus
+#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus \
+      || defined __clang__
 /* Add a typedef for older GCC compilers which don't natively support
    _Complex _Float128.  */
 typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));
@@ -91,8 +94,8 @@
 # if __HAVE_FLOAT128
 
 /* The type _Float128 exists only since GCC 7.0.  */
-#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus
-/* need a clang 5.0 case here? */
+#  if !__GNUC_PREREQ (7, 0) || defined __cplusplus \
+      || defined __clang__
 typedef __float128 _Float128;
 #  endif
 
@@ -112,7 +115,7 @@
 #else /* GCC */
 
 /* __builtin_huge_valf128 doesn't exist before GCC 7.0.  */
-#  if !__GNUC_PREREQ (7, 0)
+#  if !__GNUC_PREREQ (7, 0) && !defined __clang__
 #   define __builtin_huge_valf128() ((_Float128) __builtin_huge_val ())
 #  endif
 
@@ -121,7 +124,7 @@
    Converting a narrower sNaN to _Float128 produces a quiet NaN, so
    attempts to use _Float128 sNaNs will not work properly with older
    compilers.  */
-#  if !__GNUC_PREREQ (7, 0)
+#  if !__GNUC_PREREQ (7, 0) && !defined __clang__
 #   define __builtin_copysignf128 __builtin_copysignq
 #   define __builtin_fabsf128 __builtin_fabsq
 #   define __builtin_inff128() ((_Float128) __builtin_inf ())
@@ -133,7 +136,7 @@
    e.g.: __builtin_signbitf128, before GCC 6.  However, there has never
    been a __builtin_signbitf128 in GCC and the type-generic builtin is
    only available since GCC 6.  */
-#  if !__GNUC_PREREQ (6, 0)
+#  if !__GNUC_PREREQ (6, 0) && !defined __clang__
 #   define __builtin_signbitf128 __signbitf128
 #  endif
 
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/x86/fpu/sfp-exceptions.c b/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/x86/fpu/sfp-exceptions.c
new file mode 100644
index 0000000..3dc98c1
--- /dev/null
+++ b/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/x86/fpu/sfp-exceptions.c
@@ -0,0 +1,57 @@
+/* x86_64 soft-fp exception handling for _Float128.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <fenv.h>
+#include <float.h>
+#include <math_private.h>
+#include <soft-fp.h>
+
+void
+__sfp_handle_exceptions (int _fex)
+{
+  if (_fex & FP_EX_INVALID)
+    {
+      float f = 0.0f;
+      math_force_eval (f / f);
+    }
+  if (_fex & FP_EX_DENORM)
+    {
+      float f = FLT_MIN, g = 2.0f;
+      math_force_eval (f / g);
+    }
+  if (_fex & FP_EX_DIVZERO)
+    {
+      float f = 1.0f, g = 0.0f;
+      math_force_eval (f / g);
+    }
+  if (_fex & FP_EX_OVERFLOW)
+    {
+      float force_underflow = FLT_MAX * FLT_MAX;
+      math_force_eval (force_underflow);
+    }
+  if (_fex & FP_EX_UNDERFLOW)
+    {
+      float force_overflow = FLT_MIN * FLT_MIN;
+      math_force_eval (force_overflow);
+    }
+  if (_fex & FP_EX_INEXACT)
+    {
+      float f = 1.0f, g = 3.0f;
+      math_force_eval (f / g);
+    }
+}
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/x86/fpu/sfp-machine.h b/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/x86/fpu/sfp-machine.h
index df8906a..f06e3c0 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/x86/fpu/sfp-machine.h
+++ b/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/x86/fpu/sfp-machine.h
@@ -1,10 +1,19 @@
 /* Configure soft-fp for building sqrtf128.  Based on sfp-machine.h in
    libgcc, with soft-float and other irrelevant parts removed.  */
 
+#if defined __x86_64__ && defined __ILP32__
+typedef long long int __gcc_CMPtype;
+#else
+typedef long int __gcc_CMPtype;
+#endif
+#if !defined(__clang__) && defined(__GNUC__)
 /* The type of the result of a floating point comparison.  This must
    match `__libgcc_cmp_return__' in GCC for the target.  */
-typedef int __gcc_CMPtype __attribute__ ((mode (__libgcc_cmp_return__)));
-#define CMPtype __gcc_CMPtype
+typedef int __gcc_CMPtype_GCC __attribute__ ((mode (__libgcc_cmp_return__)));
+# define CMPtype __gcc_CMPtype
+_Static_assert(sizeof(__gcc_CMPtype) == sizeof(__gcc_CMPtype_GCC),
+	       "sizeof(__gcc_CMPtype) != sizeof(__gcc_CMPtype_GCC)");
+#endif
 
 #ifdef __x86_64__
 # define _FP_W_TYPE_SIZE	64
@@ -39,9 +48,15 @@
 
 # define FP_RND_MASK		0x6000
 
+# ifdef __AVX__
+#  define AVX_INSN_PREFIX	"v"
+# else
+#  define AVX_INSN_PREFIX	""
+# endif
+
 # define FP_INIT_ROUNDMODE					\
   do {								\
-    __asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (_fcw));	\
+    __asm__ __volatile__ (AVX_INSN_PREFIX "stmxcsr\t%0" : "=m" (_fcw)); \
   } while (0)
 #else
 # define _FP_W_TYPE_SIZE	32
diff --git a/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/x86_64/fpu/Makefile b/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/x86_64/fpu/Makefile
index 2b7d69b..ed26226 100644
--- a/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/x86_64/fpu/Makefile
+++ b/google3/third_party/grte/v5_src/glibc-2.27/sysdeps/x86_64/fpu/Makefile
@@ -25,8 +25,10 @@
 libmvec-static-only-routines = svml_finite_alias
 endif
 
-# Variables for libmvec tests.
 ifeq ($(subdir),math)
+libm-routines += sfp-exceptions
+
+# Variables for libmvec tests.
 ifeq ($(build-mathvec),yes)
 libmvec-tests += double-vlen2 double-vlen4 double-vlen4-avx2 \
 		 float-vlen4 float-vlen8 float-vlen8-avx2