code:
This file tracks updates from the "release/2.29/master" branch:
https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/release/2.29/master

Abridged commits are appended to this file.

From ec894251ef11723d10df04fcfd7bd2030c6e43ff Mon Sep 17 00:00:00 2001
From: Carlos O'Donell <carlos@redhat.com>
Date: Mon, 21 Jan 2019 22:50:12 -0500
Subject: [PATCH] nptl: Fix pthread_rwlock_try*lock stalls (Bug 23844)
diff --git a/nptl/pthread_rwlock_tryrdlock.c b/nptl/pthread_rwlock_tryrdlock.c
index 368862ff07..2f94f17f36 100644
--- a/nptl/pthread_rwlock_tryrdlock.c
+++ b/nptl/pthread_rwlock_tryrdlock.c
@@ -94,15 +94,22 @@ __pthread_rwlock_tryrdlock (pthread_rwlock_t *rwlock)
       /* Same as in __pthread_rwlock_rdlock_full:
 	 We started the read phase, so we are also responsible for
 	 updating the write-phase futex.  Relaxed MO is sufficient.
-	 Note that there can be no other reader that we have to wake
-	 because all other readers will see the read phase started by us
-	 (or they will try to start it themselves); if a writer started
-	 the read phase, we cannot have started it.  Furthermore, we
-	 cannot discard a PTHREAD_RWLOCK_FUTEX_USED flag because we will
-	 overwrite the value set by the most recent writer (or the readers
-	 before it in case of explicit hand-over) and we know that there
-	 are no waiting readers.  */
-      atomic_store_relaxed (&rwlock->__data.__wrphase_futex, 0);
+	 We have to do the same steps as a writer would when handing over the
+	 read phase to use because other readers cannot distinguish between
+	 us and the writer.
+	 Note that __pthread_rwlock_tryrdlock callers will not have to be
+	 woken up because they will either see the read phase started by us
+	 or they will try to start it themselves; however, callers of
+	 __pthread_rwlock_rdlock_full just increase the reader count and then
+	 check what state the lock is in, so they cannot distinguish between
+	 us and a writer that acquired and released the lock in the
+	 meantime.  */
+      if ((atomic_exchange_relaxed (&rwlock->__data.__wrphase_futex, 0)
+	  & PTHREAD_RWLOCK_FUTEX_USED) != 0)
+	{
+	  int private = __pthread_rwlock_get_private (rwlock);
+	  futex_wake (&rwlock->__data.__wrphase_futex, INT_MAX, private);
+	}
     }

   return 0;
diff --git a/nptl/pthread_rwlock_trywrlock.c b/nptl/pthread_rwlock_trywrlock.c
index fd37a71ce4..fae475cc70 100644
--- a/nptl/pthread_rwlock_trywrlock.c
+++ b/nptl/pthread_rwlock_trywrlock.c
@@ -46,8 +46,15 @@ __pthread_rwlock_trywrlock (pthread_rwlock_t *rwlock)
 	  &rwlock->__data.__readers, &r,
 	  r | PTHREAD_RWLOCK_WRPHASE | PTHREAD_RWLOCK_WRLOCKED))
 	{
+	  /* We have become the primary writer and we cannot have shared
+	     the PTHREAD_RWLOCK_FUTEX_USED flag with someone else, so we
+	     can simply enable blocking (see full wrlock code).  */
 	  atomic_store_relaxed (&rwlock->__data.__writers_futex, 1);
-	  atomic_store_relaxed (&rwlock->__data.__wrphase_futex, 1);
+	  /* If we started a write phase, we need to enable readers to
+	     wait.  If we did not, we must not change it because other threads
+	     may have set the PTHREAD_RWLOCK_FUTEX_USED in the meantime.  */
+	  if ((r & PTHREAD_RWLOCK_WRPHASE) == 0)
+	    atomic_store_relaxed (&rwlock->__data.__wrphase_futex, 1);
 	  atomic_store_relaxed (&rwlock->__data.__cur_writer,
 	      THREAD_GETMEM (THREAD_SELF, tid));
 	  return 0;
diff --git a/support/Makefile b/support/Makefile
index 432cf2fe6c..c15b93647c 100644
--- a/support/Makefile
+++ b/support/Makefile
@@ -129,6 +129,7 @@ libsupport-routines = \
   xpthread_mutexattr_settype \
   xpthread_once \
   xpthread_rwlock_init \
+  xpthread_rwlock_destroy \
   xpthread_rwlock_rdlock \
   xpthread_rwlock_unlock \
   xpthread_rwlock_wrlock \
diff --git a/support/xpthread_rwlock_destroy.c b/support/xpthread_rwlock_destroy.c
new file mode 100644
index 0000000000..6d6e953569
--- /dev/null
+++ b/support/xpthread_rwlock_destroy.c
@@ -0,0 +1,26 @@
+/* pthread_rwlock_destroy with error checking.
+   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 <support/xthread.h>
+
+void
+xpthread_rwlock_destroy (pthread_rwlock_t *rwlock)
+{
+  xpthread_check_return ("pthread_rwlock_destroy",
+                         pthread_rwlock_destroy (rwlock));
+}
diff --git a/support/xthread.h b/support/xthread.h
index 47c23235f3..9fe1f68b3b 100644
--- a/support/xthread.h
+++ b/support/xthread.h
@@ -84,6 +84,7 @@ void xpthread_rwlockattr_setkind_np (pthread_rwlockattr_t *attr, int pref);
 void xpthread_rwlock_wrlock (pthread_rwlock_t *rwlock);
 void xpthread_rwlock_rdlock (pthread_rwlock_t *rwlock);
 void xpthread_rwlock_unlock (pthread_rwlock_t *rwlock);
+void xpthread_rwlock_destroy (pthread_rwlock_t *rwlock);

 __END_DECLS

From 44113a8ba24af23d7bbb174f9087a6b83a76289a Mon Sep 17 00:00:00 2001
From: Stefan Liebler <stli@linux.ibm.com>
Date: Thu, 7 Feb 2019 15:18:36 +0100
Subject: [PATCH] Add compiler barriers around modifications of the robust
 mutex list for pthread_mutex_trylock. [BZ #24180]
diff --git a/nptl/pthread_mutex_trylock.c b/nptl/pthread_mutex_trylock.c
index 8fe43b8f0f..bf2869eca2 100644
--- a/nptl/pthread_mutex_trylock.c
+++ b/nptl/pthread_mutex_trylock.c
@@ -94,6 +94,9 @@ __pthread_mutex_trylock (pthread_mutex_t *mutex)
     case PTHREAD_MUTEX_ROBUST_ADAPTIVE_NP:
       THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
 		     &mutex->__data.__list.__next);
+      /* We need to set op_pending before starting the operation.  Also
+	 see comments at ENQUEUE_MUTEX.  */
+      __asm ("" ::: "memory");

       oldval = mutex->__data.__lock;
       do
@@ -119,7 +122,12 @@ __pthread_mutex_trylock (pthread_mutex_t *mutex)
 	      /* But it is inconsistent unless marked otherwise.  */
 	      mutex->__data.__owner = PTHREAD_MUTEX_INCONSISTENT;

+	      /* We must not enqueue the mutex before we have acquired it.
+		 Also see comments at ENQUEUE_MUTEX.  */
+	      __asm ("" ::: "memory");
 	      ENQUEUE_MUTEX (mutex);
+	      /* We need to clear op_pending after we enqueue the mutex.  */
+	      __asm ("" ::: "memory");
 	      THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);

 	      /* Note that we deliberately exist here.  If we fall
@@ -135,6 +143,8 @@ __pthread_mutex_trylock (pthread_mutex_t *mutex)
 	      int kind = PTHREAD_MUTEX_TYPE (mutex);
 	      if (kind == PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP)
 		{
+		  /* We do not need to ensure ordering wrt another memory
+		     access.  Also see comments at ENQUEUE_MUTEX. */
 		  THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
 				 NULL);
 		  return EDEADLK;
@@ -142,6 +152,8 @@ __pthread_mutex_trylock (pthread_mutex_t *mutex)

 	      if (kind == PTHREAD_MUTEX_ROBUST_RECURSIVE_NP)
 		{
+		  /* We do not need to ensure ordering wrt another memory
+		     access.  */
 		  THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
 				 NULL);

@@ -160,6 +172,9 @@ __pthread_mutex_trylock (pthread_mutex_t *mutex)
 							id, 0);
 	  if (oldval != 0 && (oldval & FUTEX_OWNER_DIED) == 0)
 	    {
+	      /* We haven't acquired the lock as it is already acquired by
+		 another owner.  We do not need to ensure ordering wrt another
+		 memory access.  */
 	      THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);

 	      return EBUSY;
@@ -173,13 +188,20 @@ __pthread_mutex_trylock (pthread_mutex_t *mutex)
 	      if (oldval == id)
 		lll_unlock (mutex->__data.__lock,
 			    PTHREAD_ROBUST_MUTEX_PSHARED (mutex));
+	      /* FIXME This violates the mutex destruction requirements.  See
+		 __pthread_mutex_unlock_full.  */
 	      THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
 	      return ENOTRECOVERABLE;
 	    }
 	}
       while ((oldval & FUTEX_OWNER_DIED) != 0);

+      /* We must not enqueue the mutex before we have acquired it.
+	 Also see comments at ENQUEUE_MUTEX.  */
+      __asm ("" ::: "memory");
       ENQUEUE_MUTEX (mutex);
+      /* We need to clear op_pending after we enqueue the mutex.  */
+      __asm ("" ::: "memory");
       THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);

       mutex->__data.__owner = id;
@@ -211,10 +233,15 @@ __pthread_mutex_trylock (pthread_mutex_t *mutex)
 	}

 	if (robust)
-	  /* Note: robust PI futexes are signaled by setting bit 0.  */
-	  THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
-			 (void *) (((uintptr_t) &mutex->__data.__list.__next)
-				   | 1));
+	  {
+	    /* Note: robust PI futexes are signaled by setting bit 0.  */
+	    THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending,
+			   (void *) (((uintptr_t) &mutex->__data.__list.__next)
+				     | 1));
+	    /* We need to set op_pending before starting the operation.  Also
+	       see comments at ENQUEUE_MUTEX.  */
+	    __asm ("" ::: "memory");
+	  }

 	oldval = mutex->__data.__lock;

@@ -223,12 +250,16 @@ __pthread_mutex_trylock (pthread_mutex_t *mutex)
 	  {
 	    if (kind == PTHREAD_MUTEX_ERRORCHECK_NP)
 	      {
+		/* We do not need to ensure ordering wrt another memory
+		   access.  */
 		THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
 		return EDEADLK;
 	      }

 	    if (kind == PTHREAD_MUTEX_RECURSIVE_NP)
 	      {
+		/* We do not need to ensure ordering wrt another memory
+		   access.  */
 		THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);

 		/* Just bump the counter.  */
@@ -250,6 +281,9 @@ __pthread_mutex_trylock (pthread_mutex_t *mutex)
 	  {
 	    if ((oldval & FUTEX_OWNER_DIED) == 0)
 	      {
+		/* We haven't acquired the lock as it is already acquired by
+		   another owner.  We do not need to ensure ordering wrt another
+		   memory access.  */
 		THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);

 		return EBUSY;
@@ -270,6 +304,9 @@ __pthread_mutex_trylock (pthread_mutex_t *mutex)
 	    if (INTERNAL_SYSCALL_ERROR_P (e, __err)
 		&& INTERNAL_SYSCALL_ERRNO (e, __err) == EWOULDBLOCK)
 	      {
+		/* The kernel has not yet finished the mutex owner death.
+		   We do not need to ensure ordering wrt another memory
+		   access.  */
 		THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);

 		return EBUSY;
@@ -287,7 +324,12 @@ __pthread_mutex_trylock (pthread_mutex_t *mutex)
 	    /* But it is inconsistent unless marked otherwise.  */
 	    mutex->__data.__owner = PTHREAD_MUTEX_INCONSISTENT;

+	    /* We must not enqueue the mutex before we have acquired it.
+	       Also see comments at ENQUEUE_MUTEX.  */
+	    __asm ("" ::: "memory");
 	    ENQUEUE_MUTEX (mutex);
+	    /* We need to clear op_pending after we enqueue the mutex.  */
+	    __asm ("" ::: "memory");
 	    THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);

 	    /* Note that we deliberately exit here.  If we fall
@@ -310,13 +352,20 @@ __pthread_mutex_trylock (pthread_mutex_t *mutex)
 						  PTHREAD_ROBUST_MUTEX_PSHARED (mutex)),
 			      0, 0);

+	    /* To the kernel, this will be visible after the kernel has
+	       acquired the mutex in the syscall.  */
 	    THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
 	    return ENOTRECOVERABLE;
 	  }

 	if (robust)
 	  {
+	    /* We must not enqueue the mutex before we have acquired it.
+	       Also see comments at ENQUEUE_MUTEX.  */
+	    __asm ("" ::: "memory");
 	    ENQUEUE_MUTEX_PI (mutex);
+	    /* We need to clear op_pending after we enqueue the mutex.  */
+	    __asm ("" ::: "memory");
 	    THREAD_SETMEM (THREAD_SELF, robust_head.list_op_pending, NULL);
 	  }

From c096b008d2671028c21ac8cf01f18a2083e73c44 Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Fri, 8 Feb 2019 12:54:41 +0100
Subject: [PATCH] nptl: Avoid fork handler lock for async-signal-safe fork [BZ
 #24161]
--- a/nptl/register-atfork.c
+++ b/nptl/register-atfork.c
@@ -107,13 +107,14 @@ __unregister_atfork (void *dso_handle)
 }

 void
-__run_fork_handlers (enum __run_fork_handler_type who)
+__run_fork_handlers (enum __run_fork_handler_type who, _Bool do_locking)
 {
   struct fork_handler *runp;

   if (who == atfork_run_prepare)
     {
-      lll_lock (atfork_lock, LLL_PRIVATE);
+      if (do_locking)
+	lll_lock (atfork_lock, LLL_PRIVATE);
       size_t sl = fork_handler_list_size (&fork_handlers);
       for (size_t i = sl; i > 0; i--)
 	{
@@ -133,7 +134,8 @@ __run_fork_handlers (enum __run_fork_handler_type who)
 	  else if (who == atfork_run_parent && runp->parent_handler)
 	    runp->parent_handler ();
 	}
-      lll_unlock (atfork_lock, LLL_PRIVATE);
+      if (do_locking)
+	lll_unlock (atfork_lock, LLL_PRIVATE);
     }
 }

diff --git a/sysdeps/nptl/fork.c b/sysdeps/nptl/fork.c
index bd68f18b45..14b69a6f89 100644
--- a/sysdeps/nptl/fork.c
+++ b/sysdeps/nptl/fork.c
@@ -55,7 +55,7 @@ __libc_fork (void)
      but our current fork implementation is not.  */
   bool multiple_threads = THREAD_GETMEM (THREAD_SELF, header.multiple_threads);

-  __run_fork_handlers (atfork_run_prepare);
+  __run_fork_handlers (atfork_run_prepare, multiple_threads);

   /* If we are not running multiple threads, we do not have to
      preserve lock state.  If fork runs from a signal handler, only
@@ -134,7 +134,7 @@ __libc_fork (void)
       __rtld_lock_initialize (GL(dl_load_lock));

       /* Run the handlers registered for the child.  */
-      __run_fork_handlers (atfork_run_child);
+      __run_fork_handlers (atfork_run_child, multiple_threads);
     }
   else
     {
@@ -149,7 +149,7 @@ __libc_fork (void)
 	}

       /* Run the handlers registered for the parent.  */
-      __run_fork_handlers (atfork_run_parent);
+      __run_fork_handlers (atfork_run_parent, multiple_threads);
     }

   return pid;
diff --git a/sysdeps/nptl/fork.h b/sysdeps/nptl/fork.h
index a1c3b26b68..99ed76034b 100644
--- a/sysdeps/nptl/fork.h
+++ b/sysdeps/nptl/fork.h
@@ -52,10 +52,12 @@ enum __run_fork_handler_type
    - atfork_run_child: run all the CHILD_HANDLER and unlocks the internal
 		       lock.
    - atfork_run_parent: run all the PARENT_HANDLER and unlocks the internal
-			lock.  */
-extern void __run_fork_handlers (enum __run_fork_handler_type who)
-  attribute_hidden;
+			lock.
+
+   Perform locking only if DO_LOCKING.  */
+extern void __run_fork_handlers (enum __run_fork_handler_type who,
+				 _Bool do_locking) attribute_hidden;

 /* C library side function to register new fork handlers.  */
 extern int __register_atfork (void (*__prepare) (void),

From 067fc32968b601493f4b247a3ac00caeea3f3d61 Mon Sep 17 00:00:00 2001
From: Florian Weimer <fweimer@redhat.com>
Date: Fri, 15 Feb 2019 21:27:01 +0100
Subject: [PATCH] nptl: Fix invalid Systemtap probe in pthread_join [BZ #24211]
diff --git a/nptl/pthread_join_common.c b/nptl/pthread_join_common.c
index ecb78ffba5..366feb376b 100644
--- a/nptl/pthread_join_common.c
+++ b/nptl/pthread_join_common.c
@@ -86,6 +86,7 @@ __pthread_timedjoin_ex (pthread_t threadid, void **thread_return,
       pthread_cleanup_pop (0);
     }

+  void *pd_result = pd->result;
   if (__glibc_likely (result == 0))
     {
       /* We mark the thread as terminated and as joined.  */
@@ -93,7 +94,7 @@ __pthread_timedjoin_ex (pthread_t threadid, void **thread_return,

       /* Store the return value if the caller is interested.  */
       if (thread_return != NULL)
-	*thread_return = pd->result;
+	*thread_return = pd_result;

       /* Free the TCB.  */
       __free_tcb (pd);
@@ -101,7 +102,7 @@ __pthread_timedjoin_ex (pthread_t threadid, void **thread_return,
   else
     pd->joinid = NULL;

-  LIBC_PROBE (pthread_join_ret, 3, threadid, result, pd->result);
+  LIBC_PROBE (pthread_join_ret, 3, threadid, result, pd_result);

   return result;
 }

From bc6f839fb4066be83272c735e662850af2595777 Mon Sep 17 00:00:00 2001
From: Stefan Liebler <stli@linux.ibm.com>
Date: Wed, 13 Mar 2019 10:45:35 +0100
Subject: [PATCH] Fix output of LD_SHOW_AUXV=1.
diff --git a/elf/dl-sysdep.c b/elf/dl-sysdep.c
index 5f6c679a3f..5d19b100b2 100644
--- a/elf/dl-sysdep.c
+++ b/elf/dl-sysdep.c
@@ -328,14 +328,9 @@ _dl_show_auxv (void)
       assert (AT_NULL == 0);
       assert (AT_IGNORE == 1);

-      if (av->a_type == AT_HWCAP || av->a_type == AT_HWCAP2
-	  || AT_L1I_CACHEGEOMETRY || AT_L1D_CACHEGEOMETRY
-	  || AT_L2_CACHEGEOMETRY || AT_L3_CACHEGEOMETRY)
-	{
-	  /* These are handled in a special way per platform.  */
-	  if (_dl_procinfo (av->a_type, av->a_un.a_val) == 0)
-	    continue;
-	}
+      /* Some entries are handled in a special way per platform.  */
+      if (_dl_procinfo (av->a_type, av->a_un.a_val) == 0)
+	continue;

       if (idx < sizeof (auxvars) / sizeof (auxvars[0])
 	  && auxvars[idx].form != unknown)
diff --git a/sysdeps/powerpc/dl-procinfo.h b/sysdeps/powerpc/dl-procinfo.h
index f542f7318f..dfc3b33a72 100644
--- a/sysdeps/powerpc/dl-procinfo.h
+++ b/sysdeps/powerpc/dl-procinfo.h
@@ -225,7 +225,7 @@ _dl_procinfo (unsigned int type, unsigned long int word)
 	break;
       }
     default:
-      /* This should not happen.  */
+      /* Fallback to generic output mechanism.  */
       return -1;
     }
    _dl_printf ("\n");
diff --git a/sysdeps/sparc/dl-procinfo.h b/sysdeps/sparc/dl-procinfo.h
index 282b8c5117..64ee267fc7 100644
--- a/sysdeps/sparc/dl-procinfo.h
+++ b/sysdeps/sparc/dl-procinfo.h
@@ -31,8 +31,8 @@ _dl_procinfo (unsigned int type, unsigned long int word)
 {
   int i;

-  /* Fallback to unknown output mechanism.  */
-  if (type == AT_HWCAP2)
+  /* Fallback to generic output mechanism.  */
+  if (type != AT_HWCAP)
     return -1;

   _dl_printf ("AT_HWCAP:   ");
diff --git a/sysdeps/unix/sysv/linux/arm/dl-procinfo.h b/sysdeps/unix/sysv/linux/arm/dl-procinfo.h
index 66c00297b7..05c62c8687 100644
--- a/sysdeps/unix/sysv/linux/arm/dl-procinfo.h
+++ b/sysdeps/unix/sysv/linux/arm/dl-procinfo.h
@@ -67,7 +67,7 @@ _dl_procinfo (unsigned int type, unsigned long int word)
 	break;
       }
     default:
-      /* This should not happen.  */
+      /* Fallback to generic output mechanism.  */
       return -1;
     }
   _dl_printf ("\n");
diff --git a/sysdeps/unix/sysv/linux/i386/dl-procinfo.h b/sysdeps/unix/sysv/linux/i386/dl-procinfo.h
index 22b43431bc..0585cdaa9c 100644
--- a/sysdeps/unix/sysv/linux/i386/dl-procinfo.h
+++ b/sysdeps/unix/sysv/linux/i386/dl-procinfo.h
@@ -30,8 +30,8 @@ _dl_procinfo (unsigned int type, unsigned long int word)
      in the kernel sources.  */
   int i;

-  /* Fallback to unknown output mechanism.  */
-  if (type == AT_HWCAP2)
+  /* Fallback to generic output mechanism.  */
+  if (type != AT_HWCAP)
     return -1;

   _dl_printf ("AT_HWCAP:   ");
diff --git a/sysdeps/unix/sysv/linux/s390/dl-procinfo.h b/sysdeps/unix/sysv/linux/s390/dl-procinfo.h
index 19329a335b..d67fde368f 100644
--- a/sysdeps/unix/sysv/linux/s390/dl-procinfo.h
+++ b/sysdeps/unix/sysv/linux/s390/dl-procinfo.h
@@ -32,8 +32,8 @@ _dl_procinfo (unsigned int type, unsigned long int word)
      in the kernel sources.  */
   int i;

-  /* Fallback to unknown output mechanism.  */
-  if (type == AT_HWCAP2)
+  /* Fallback to generic output mechanism.  */
+  if (type != AT_HWCAP)
     return -1;

   _dl_printf ("AT_HWCAP:   ");

From e28ad442e73b00ae2047d89c8cc7f9b2a0de5436 Mon Sep 17 00:00:00 2001
From: TAMUKI Shoichi <tamuki@linet.gr.jp>
Date: Sat, 2 Mar 2019 21:00:28 +0900
Subject: [PATCH] ja_JP: Change the offset for Taisho gan-nen from 2 to 1 [BZ
 #24162]
diff --git a/localedata/locales/ja_JP b/localedata/locales/ja_JP
index 1fd2fee44b..9bfbb2bb9b 100644
--- a/localedata/locales/ja_JP
+++ b/localedata/locales/ja_JP
@@ -14951,7 +14951,7 @@ era	"+:2:1990//01//01:+*:<U5E73><U6210>:%EC%Ey<U5E74>";/
 	"+:2:1927//01//01:1989//01//07:<U662D><U548C>:%EC%Ey<U5E74>";/
 	"+:1:1926//12//25:1926//12//31:<U662D><U548C>:%EC<U5143><U5E74>";/
 	"+:2:1913//01//01:1926//12//24:<U5927><U6B63>:%EC%Ey<U5E74>";/
-	"+:2:1912//07//30:1912//12//31:<U5927><U6B63>:%EC<U5143><U5E74>";/
+	"+:1:1912//07//30:1912//12//31:<U5927><U6B63>:%EC<U5143><U5E74>";/
 	"+:6:1873//01//01:1912//07//29:<U660E><U6CBB>:%EC%Ey<U5E74>";/
 	"+:1:0001//01//01:1872//12//31:<U897F><U66A6>:%EC%Ey<U5E74>";/
 	"+:1:-0001//12//31:-*:<U7D00><U5143><U524D>:%EC%Ey<U5E74>"

From 0941350c20a52447e53c5169354408e3db591f73 Mon Sep 17 00:00:00 2001
From: TAMUKI Shoichi <tamuki@linet.gr.jp>
Date: Tue, 2 Apr 2019 16:46:55 +0900
Subject: [PATCH] ja_JP locale: Add entry for the new Japanese era [BZ #22964]
diff --git a/localedata/locales/ja_JP b/localedata/locales/ja_JP
index 9bfbb2bb9b..c64aaaff55 100644
--- a/localedata/locales/ja_JP
+++ b/localedata/locales/ja_JP
@@ -14946,7 +14946,9 @@ am_pm	"<U5348><U524D>";"<U5348><U5F8C>"

 t_fmt_ampm "%p%I<U6642>%M<U5206>%S<U79D2>"

-era	"+:2:1990//01//01:+*:<U5E73><U6210>:%EC%Ey<U5E74>";/
+era	"+:2:2020//01//01:+*:<U4EE4><U548C>:%EC%Ey<U5E74>";/
+	"+:1:2019//05//01:2019//12//31:<U4EE4><U548C>:%EC<U5143><U5E74>";/
+	"+:2:1990//01//01:2019//04//30:<U5E73><U6210>:%EC%Ey<U5E74>";/
 	"+:1:1989//01//08:1989//12//31:<U5E73><U6210>:%EC<U5143><U5E74>";/
 	"+:2:1927//01//01:1989//01//07:<U662D><U548C>:%EC%Ey<U5E74>";/
 	"+:1:1926//12//25:1926//12//31:<U662D><U548C>:%EC<U5143><U5E74>";/

From 52b7cd6e9a701bb203023d56e84551943dc6a4c0 Mon Sep 17 00:00:00 2001
From: Adam Maris <amaris@redhat.com>
Date: Thu, 14 Mar 2019 16:51:16 -0400
Subject: [PATCH] malloc: Check for large bin list corruption when inserting
 unsorted chunk
diff --git a/malloc/malloc.c b/malloc/malloc.c
index feaf7ee0bf..ce771375b6 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -3876,10 +3876,14 @@ _int_malloc (mstate av, size_t bytes)
                         {
                           victim->fd_nextsize = fwd;
                           victim->bk_nextsize = fwd->bk_nextsize;
+                          if (__glibc_unlikely (fwd->bk_nextsize->fd_nextsize != fwd))
+                            malloc_printerr ("malloc(): largebin double linked list corrupted (nextsize)");
                           fwd->bk_nextsize = victim;
                           victim->bk_nextsize->fd_nextsize = victim;
                         }
                       bck = fwd->bk;
+                      if (bck->fd != fwd)
+                        malloc_printerr ("malloc(): largebin double linked list corrupted (bk)");
                     }
                 }
               else

From c6177be4b92d5d7df50a785652d1912db511423e Mon Sep 17 00:00:00 2001
From: Andreas Schwab <schwab@suse.de>
Date: Wed, 15 May 2019 17:09:05 +0200
Subject: [PATCH] Fix crash in _IO_wfile_sync (bug 20568)
diff --git a/libio/wfileops.c b/libio/wfileops.c
index 78f20486e5..bab2ba4892 100644
--- a/libio/wfileops.c
+++ b/libio/wfileops.c
@@ -508,11 +508,12 @@ _IO_wfile_sync (FILE *fp)
 	     generate the wide characters up to the current reading
 	     position.  */
 	  int nread;
-
+	  size_t wnread = (fp->_wide_data->_IO_read_ptr
+			   - fp->_wide_data->_IO_read_base);
 	  fp->_wide_data->_IO_state = fp->_wide_data->_IO_last_state;
 	  nread = (*cv->__codecvt_do_length) (cv, &fp->_wide_data->_IO_state,
 					      fp->_IO_read_base,
-					      fp->_IO_read_end, delta);
+					      fp->_IO_read_end, wnread);
 	  fp->_IO_read_ptr = fp->_IO_read_base + nread;
 	  delta = -(fp->_IO_read_end - fp->_IO_read_base - nread);
 	}

From e3f828b8bd6e21922da8be8dee35edef09382d8d Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Wed, 15 May 2019 17:14:01 +0200
Subject: [PATCH] dlfcn: Guard __dlerror_main_freeres with __libc_once_get
 (once) [BZ#24476]
diff --git a/dlfcn/dlerror.c b/dlfcn/dlerror.c
index 27376582d0..ca42c126c1 100644
--- a/dlfcn/dlerror.c
+++ b/dlfcn/dlerror.c
@@ -72,9 +72,16 @@ __dlerror (void)
   __libc_once (once, init);

   /* Get error string.  */
-  result = (struct dl_action_result *) __libc_getspecific (key);
-  if (result == NULL)
-    result = &last_result;
+  if (static_buf != NULL)
+    result = static_buf;
+  else
+    {
+      /* init () has been run and we don't use the static buffer.
+	 So we have a valid key.  */
+      result = (struct dl_action_result *) __libc_getspecific (key);
+      if (result == NULL)
+	result = &last_result;
+    }

   /* Test whether we already returned the string.  */
   if (result->returned != 0)
@@ -230,13 +237,19 @@ free_key_mem (void *mem)
 void
 __dlerror_main_freeres (void)
 {
-  void *mem;
   /* Free the global memory if used.  */
   check_free (&last_result);
-  /* Free the TSD memory if used.  */
-  mem = __libc_getspecific (key);
-  if (mem != NULL)
-    free_key_mem (mem);
+
+  if (__libc_once_get (once) && static_buf == NULL)
+    {
+      /* init () has been run and we don't use the static buffer.
+	 So we have a valid key.  */
+      void *mem;
+      /* Free the TSD memory if used.  */
+      mem = __libc_getspecific (key);
+      if (mem != NULL)
+	free_key_mem (mem);
+    }
 }

 struct dlfcn_hook *_dlfcn_hook __attribute__((nocommon));

From 95d66fecaabbc92ab53027e808f0fc1929c9f21a Mon Sep 17 00:00:00 2001
From: Wilco Dijkstra <wdijkstr@arm.com>
Date: Fri, 10 May 2019 16:38:21 +0100
Subject: [PATCH] Fix tcache count maximum (BZ #24531)
diff --git a/malloc/malloc.c b/malloc/malloc.c
index ce771375b6..0abd653be2 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -2919,6 +2919,8 @@ typedef struct tcache_perthread_struct
   tcache_entry *entries[TCACHE_MAX_BINS];
 } tcache_perthread_struct;

+#define MAX_TCACHE_COUNT 127	/* Maximum value of counts[] entries.  */
+
 static __thread bool tcache_shutting_down = false;
 static __thread tcache_perthread_struct *tcache = NULL;

@@ -5124,8 +5126,11 @@ static inline int
 __always_inline
 do_set_tcache_count (size_t value)
 {
-  LIBC_PROBE (memory_tunable_tcache_count, 2, value, mp_.tcache_count);
-  mp_.tcache_count = value;
+  if (value <= MAX_TCACHE_COUNT)
+    {
+      LIBC_PROBE (memory_tunable_tcache_count, 2, value, mp_.tcache_count);
+      mp_.tcache_count = value;
+    }
   return 1;
 }

From 34fb5f61d3c3f4b8fc616ea259fa19168b58ecd4 Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Wed, 13 Feb 2019 01:20:51 +0000
Subject: [PATCH] libio: do not attempt to free wide buffers of legacy streams
 [BZ #24228]
diff --git a/libio/genops.c b/libio/genops.c
index 2a0d9b81df..11a15549e8 100644
--- a/libio/genops.c
+++ b/libio/genops.c
@@ -789,9 +789,16 @@ _IO_unbuffer_all (void)

   for (fp = (FILE *) _IO_list_all; fp; fp = fp->_chain)
     {
+      int legacy = 0;
+
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
+      if (__glibc_unlikely (_IO_vtable_offset (fp) != 0))
+	legacy = 1;
+#endif
+
       if (! (fp->_flags & _IO_UNBUFFERED)
 	  /* Iff stream is un-orientated, it wasn't used. */
-	  && fp->_mode != 0)
+	  && (legacy || fp->_mode != 0))
 	{
 #ifdef _IO_MTSAFE_IO
 	  int cnt;
@@ -805,7 +812,7 @@ _IO_unbuffer_all (void)
 	      __sched_yield ();
 #endif

-	  if (! dealloc_buffers && !(fp->_flags & _IO_USER_BUF))
+	  if (! legacy && ! dealloc_buffers && !(fp->_flags & _IO_USER_BUF))
 	    {
 	      fp->_flags |= _IO_USER_BUF;

@@ -816,7 +823,7 @@ _IO_unbuffer_all (void)

 	  _IO_SETBUF (fp, NULL, 0);

-	  if (fp->_mode > 0)
+	  if (! legacy && fp->_mode > 0)
 	    _IO_wsetb (fp, NULL, NULL, 0);

 #ifdef _IO_MTSAFE_IO
@@ -827,7 +834,8 @@ _IO_unbuffer_all (void)

       /* Make sure that never again the wide char functions can be
 	 used.  */
-      fp->_mode = -1;
+      if (! legacy)
+	fp->_mode = -1;
     }

 #ifdef _IO_MTSAFE_IO


code:
This patch is taken from debian's glibc package (generate-supported.mk).
It install the localedata/SUPPORTED file of the glibc. This file lists
all the supported locales of the glibc.

diff --git a/localedata/Makefile b/localedata/Makefile
index 65079f9eb8..14818f84e0 100644
--- a/localedata/Makefile
+++ b/localedata/Makefile
@@ -169,7 +169,8 @@ endif
 # Files to install.
 install-others := $(addprefix $(inst_i18ndir)/, \
 			      $(addsuffix .gz, $(charmaps)) \
-			      $(locales))
+			      $(locales)) \
+                   $(inst_i18ndir)/SUPPORTED

 tests: $(objdir)/iconvdata/gconv-modules

@@ -380,6 +381,14 @@ endif

 include SUPPORTED

+$(inst_i18ndir)/SUPPORTED: SUPPORTED $(+force)
+	for locale in $(SUPPORTED-LOCALES); do \
+		[ $$locale = true ] && continue; \
+		echo $$locale | sed 's,/, ,' >> LOCALES; \
+	done
+	$(make-target-directory)
+	$(INSTALL_DATA) LOCALES $@
+
 INSTALL-SUPPORTED-LOCALE-ARCHIVE=$(addprefix install-archive-, $(SUPPORTED-LOCALES))
 INSTALL-SUPPORTED-LOCALE-FILES=$(addprefix install-files-, $(SUPPORTED-LOCALES))

repo_name: maximed/guix

license: mit


code:
https://sourceware.org/git/gitweb.cgi?p=glibc.git;a=patch;h=5460617d1567657621107d895ee2dd83bc1f88f2
with ChangeLog removed

From 5460617d1567657621107d895ee2dd83bc1f88f2 Mon Sep 17 00:00:00 2001
From: Paul Pluzhnikov <ppluzhnikov@google.com>
Date: Tue, 8 May 2018 18:12:41 -0700
Subject: [PATCH] Fix BZ 22786: integer addition overflow may cause stack
 buffer overflow when realpath() input length is close to SSIZE_MAX.

2018-05-09  Paul Pluzhnikov  <ppluzhnikov@google.com>

	[BZ #22786]
	* stdlib/canonicalize.c (__realpath): Fix overflow in path length
	computation.
	* stdlib/Makefile (test-bz22786): New test.
	* stdlib/test-bz22786.c: New test.
---
 ChangeLog             |  8 +++++
 stdlib/Makefile       |  2 +-
 stdlib/canonicalize.c |  2 +-
 stdlib/test-bz22786.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 100 insertions(+), 2 deletions(-)
 create mode 100644 stdlib/test-bz22786.c

diff --git a/stdlib/Makefile b/stdlib/Makefile
index af1643c..1ddb1f9 100644
--- a/stdlib/Makefile
+++ b/stdlib/Makefile
@@ -84,7 +84,7 @@ tests		:= tst-strtol tst-strtod testmb testrand testsort testdiv   \
 		   tst-cxa_atexit tst-on_exit test-atexit-race 		    \
 		   test-at_quick_exit-race test-cxa_atexit-race             \
 		   test-on_exit-race test-dlclose-exit-race 		    \
-		   tst-makecontext-align
+		   tst-makecontext-align test-bz22786

 tests-internal	:= tst-strtod1i tst-strtod3 tst-strtod4 tst-strtod5i \
 		   tst-tls-atexit tst-tls-atexit-nodelete
diff --git a/stdlib/canonicalize.c b/stdlib/canonicalize.c
index 4135f3f..390fb43 100644
--- a/stdlib/canonicalize.c
+++ b/stdlib/canonicalize.c
@@ -181,7 +181,7 @@ __realpath (const char *name, char *resolved)
 		extra_buf = __alloca (path_max);

 	      len = strlen (end);
-	      if ((long int) (n + len) >= path_max)
+	      if (path_max - n <= len)
 		{
 		  __set_errno (ENAMETOOLONG);
 		  goto error;
diff --git a/stdlib/test-bz22786.c b/stdlib/test-bz22786.c
new file mode 100644
index 0000000..e7837f9
--- /dev/null
+++ b/stdlib/test-bz22786.c
@@ -0,0 +1,90 @@
+/* Bug 22786: test for buffer overflow in realpath.
+   Copyright (C) 2018 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/>.  */
+
+/* This file must be run from within a directory called "stdlib".  */
+
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <support/test-driver.h>
+#include <libc-diag.h>
+
+static int
+do_test (void)
+{
+  const char dir[] = "bz22786";
+  const char lnk[] = "bz22786/symlink";
+
+  rmdir (dir);
+  if (mkdir (dir, 0755) != 0 && errno != EEXIST)
+    {
+      printf ("mkdir %s: %m\n", dir);
+      return EXIT_FAILURE;
+    }
+  if (symlink (".", lnk) != 0 && errno != EEXIST)
+    {
+      printf ("symlink (%s, %s): %m\n", dir, lnk);
+      return EXIT_FAILURE;
+    }
+
+  const size_t path_len = (size_t) INT_MAX + 1;
+
+  DIAG_PUSH_NEEDS_COMMENT;
+#if __GNUC_PREREQ (7, 0)
+  /* GCC 7 warns about too-large allocations; here we need such
+     allocation to succeed for the test to work.  */
+  DIAG_IGNORE_NEEDS_COMMENT (7, "-Walloc-size-larger-than=");
+#endif
+  char *path = malloc (path_len);
+  DIAG_POP_NEEDS_COMMENT;
+
+  if (path == NULL)
+    {
+      printf ("malloc (%zu): %m\n", path_len);
+      return EXIT_UNSUPPORTED;
+    }
+
+  /* Construct very long path = "bz22786/symlink/aaaa....."  */
+  char *p = mempcpy (path, lnk, sizeof (lnk) - 1);
+  *(p++) = '/';
+  memset (p, 'a', path_len - (path - p) - 2);
+  p[path_len - (path - p) - 1] = '\0';
+
+  /* This call crashes before the fix for bz22786 on 32-bit platforms.  */
+  p = realpath (path, NULL);
+
+  if (p != NULL || errno != ENAMETOOLONG)
+    {
+      printf ("realpath: %s (%m)", p);
+      return EXIT_FAILURE;
+    }
+
+  /* Cleanup.  */
+  unlink (lnk);
+  rmdir (dir);
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test
+#include <support/test-driver.c>
--
2.9.3


code:
https://sourceware.org/git/gitweb.cgi?p=glibc.git;a=patch;h=9aaaab7c6e4176e61c59b0a63c6ba906d875dc0e
with the ChangeLog removed

From 9aaaab7c6e4176e61c59b0a63c6ba906d875dc0e Mon Sep 17 00:00:00 2001
From: Andreas Schwab <schwab@suse.de>
Date: Tue, 22 May 2018 10:37:59 +0200
Subject: [PATCH] Don't write beyond destination in
 __mempcpy_avx512_no_vzeroupper (bug 23196)

When compiled as mempcpy, the return value is the end of the destination
buffer, thus it cannot be used to refer to the start of it.
---
 ChangeLog                                               | 9 +++++++++
 string/test-mempcpy.c                                   | 1 +
 sysdeps/x86_64/multiarch/memmove-avx512-no-vzeroupper.S | 5 +++--
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/string/test-mempcpy.c b/string/test-mempcpy.c
index c08fba8..d98ecdd 100644
--- a/string/test-mempcpy.c
+++ b/string/test-mempcpy.c
@@ -18,6 +18,7 @@
    <http://www.gnu.org/licenses/>.  */

 #define MEMCPY_RESULT(dst, len) (dst) + (len)
+#define MIN_PAGE_SIZE 131072
 #define TEST_MAIN
 #define TEST_NAME "mempcpy"
 #include "test-string.h"
diff --git a/sysdeps/x86_64/multiarch/memmove-avx512-no-vzeroupper.S b/sysdeps/x86_64/multiarch/memmove-avx512-no-vzeroupper.S
index 23c0f7a..effc3ac 100644
--- a/sysdeps/x86_64/multiarch/memmove-avx512-no-vzeroupper.S
+++ b/sysdeps/x86_64/multiarch/memmove-avx512-no-vzeroupper.S
@@ -336,6 +336,7 @@ L(preloop_large):
 	vmovups	(%rsi), %zmm4
 	vmovups	0x40(%rsi), %zmm5

+	mov	%rdi, %r11
 /* Align destination for access with non-temporal stores in the loop.  */
 	mov	%rdi, %r8
 	and	$-0x80, %rdi
@@ -366,8 +367,8 @@ L(gobble_256bytes_nt_loop):
 	cmp	$256, %rdx
 	ja	L(gobble_256bytes_nt_loop)
 	sfence
-	vmovups	%zmm4, (%rax)
-	vmovups	%zmm5, 0x40(%rax)
+	vmovups	%zmm4, (%r11)
+	vmovups	%zmm5, 0x40(%r11)
 	jmp	L(check)

 L(preloop_large_bkw):
--
2.9.3


code:
Fix CVE-2019-19126:

https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-19126
https://sourceware.org/bugzilla/show_bug.cgi?id=25204

Taken from upstream:
https://sourceware.org/git/?p=glibc.git;a=commit;h=37c90e117310728a4ad1eb998c0bbe7d79c4a398

diff --git a/sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h b/sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h
index 975cbe2..df2cdfd 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h
+++ b/sysdeps/unix/sysv/linux/x86_64/64/dl-librecon.h
@@ -31,7 +31,8 @@
    environment variable, LD_PREFER_MAP_32BIT_EXEC.  */
 #define EXTRA_LD_ENVVARS \
   case 21:								  \
-    if (memcmp (envline, "PREFER_MAP_32BIT_EXEC", 21) == 0)		  \
+    if (!__libc_enable_secure						  \
+	&& memcmp (envline, "PREFER_MAP_32BIT_EXEC", 21) == 0)		  \
       GLRO(dl_x86_cpu_features).feature[index_arch_Prefer_MAP_32BIT_EXEC] \
 	|= bit_arch_Prefer_MAP_32BIT_EXEC;				  \
     break;


code:
Fix <https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-7309>.

Taken from this upstream commit, sans ChangeLog updates and tests:
<https://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=3f635fb43389b54f682fc9ed2acc0b2aaf4a923d>.

diff --git a/sysdeps/x86_64/memcmp.S b/sysdeps/x86_64/memcmp.S
index 1fc487caa5..1322bb3b92 100644
--- a/sysdeps/x86_64/memcmp.S
+++ b/sysdeps/x86_64/memcmp.S
@@ -21,14 +21,18 @@

 	.text
 ENTRY (memcmp)
-	test	%rdx, %rdx
+#ifdef __ILP32__
+	/* Clear the upper 32 bits.  */
+	movl	%edx, %edx
+#endif
+	test	%RDX_LP, %RDX_LP
 	jz	L(finz)
 	cmpq	$1, %rdx
-	jle	L(finr1b)
+	jbe	L(finr1b)
 	subq	%rdi, %rsi
 	movq	%rdx, %r10
 	cmpq	$32, %r10
-	jge	L(gt32)
+	jae	L(gt32)
 	/* Handle small chunks and last block of less than 32 bytes.  */
 L(small):
 	testq	$1, %r10
@@ -156,7 +160,7 @@ L(A32):
 	movq	%r11, %r10
 	andq	$-32, %r10
 	cmpq	%r10, %rdi
-        jge	L(mt16)
+        jae	L(mt16)
 	/* Pre-unroll to be ready for unrolled 64B loop.  */
 	testq	$32, %rdi
 	jz	L(A64)
@@ -178,7 +182,7 @@ L(A64):
 	movq	%r11, %r10
 	andq	$-64, %r10
 	cmpq	%r10, %rdi
-        jge	L(mt32)
+        jae	L(mt32)

 L(A64main):
 	movdqu    (%rdi,%rsi), %xmm0
@@ -216,7 +220,7 @@ L(mt32):
 	movq	%r11, %r10
 	andq	$-32, %r10
 	cmpq	%r10, %rdi
-        jge	L(mt16)
+        jae	L(mt16)

 L(A32main):
 	movdqu    (%rdi,%rsi), %xmm0
@@ -254,7 +258,7 @@ L(ATR):
 	movq	%r11, %r10
 	andq	$-32, %r10
 	cmpq	%r10, %rdi
-        jge	L(mt16)
+        jae	L(mt16)
 	testq	$16, %rdi
 	jz	L(ATR32)

@@ -325,7 +329,7 @@ L(ATR64main):
 	movq	%r11, %r10
 	andq	$-32, %r10
 	cmpq	%r10, %rdi
-        jge	L(mt16)
+        jae	L(mt16)

 L(ATR32res):
 	movdqa    (%rdi,%rsi), %xmm0


code:
Fix <https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-9169>.

Taken from this upstream commit, sans ChangeLog updates:
https://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=583dd860d5b833037175247230a328f0050dbfe9

diff --git a/posix/regexec.c b/posix/regexec.c
index 91d5a797b8..084b1222d9 100644
--- a/posix/regexec.c
+++ b/posix/regexec.c
@@ -1293,8 +1293,10 @@ proceed_next_node (const re_match_context_t *mctx, Idx nregs, regmatch_t *regs,
 	      else if (naccepted)
 		{
 		  char *buf = (char *) re_string_get_buffer (&mctx->input);
-		  if (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx,
-			      naccepted) != 0)
+		  if (mctx->input.valid_len - *pidx < naccepted
+		      || (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx,
+				  naccepted)
+			  != 0))
 		    return -1;
 		}
 	    }


code:
This patch allows libc to be used with the heavily-patched kernel found
on CentOS 6, which identifies itself as 2.6.32.

See <https://lists.gnu.org/archive/html/guix-devel/2018-02/msg00392.html>.

Patch taken from Nixpkgs.

diff --git a/sysdeps/unix/sysv/linux/configure b/sysdeps/unix/sysv/linux/configure
index cace758c01..38fe7fe0b0 100644
--- a/sysdeps/unix/sysv/linux/configure
+++ b/sysdeps/unix/sysv/linux/configure
@@ -69,7 +69,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for kernel header at least $minimum_kernel" >&5
 $as_echo_n "checking for kernel header at least $minimum_kernel... " >&6; }
 decnum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/(\1 * 65536 + \2 * 256 + \3)/'`;
-abinum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
+abinum=`echo "2.6.32.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <linux/version.h>
diff --git a/sysdeps/unix/sysv/linux/configure.ac b/sysdeps/unix/sysv/linux/configure.ac
index 13abda0a51..6abc12eaed 100644
--- a/sysdeps/unix/sysv/linux/configure.ac
+++ b/sysdeps/unix/sysv/linux/configure.ac
@@ -50,7 +50,7 @@ fi
 AC_MSG_CHECKING(for kernel header at least $minimum_kernel)
 changequote(,)dnl
 decnum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/(\1 * 65536 + \2 * 256 + \3)/'`;
-abinum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
+abinum=`echo "2.6.32.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
 changequote([,])dnl
 AC_TRY_COMPILE([#include <linux/version.h>
 #if LINUX_VERSION_CODE < $decnum
diff --git a/sysdeps/unix/sysv/linux/dl-osinfo.h b/sysdeps/unix/sysv/linux/dl-osinfo.h
index 823cd8224d..482caaeeec 100644
--- a/sysdeps/unix/sysv/linux/dl-osinfo.h
+++ b/sysdeps/unix/sysv/linux/dl-osinfo.h
@@ -39,7 +39,7 @@
 	  GLRO(dl_osversion) = version;					      \
 									      \
 	/* Now we can test with the required version.  */		      \
-	if (__LINUX_KERNEL_VERSION > 0 && version < __LINUX_KERNEL_VERSION)   \
+	if (__LINUX_KERNEL_VERSION > 0 && version < __LINUX_KERNEL_VERSION && version != 0x020620)   \
 	  /* Not sufficent.  */						      \
 	  FATAL ("FATAL: kernel too old\n");				      \
       }									      \


code:
This patch enables building glibc-2.2.5 using TCC and GNU Make 4.x and Mes C Library.

  * Makefile: Do not link with (non-existent) libgc_eh.
  * Makefile: Add SHELL variable, ready for substitution, export it.
  * Makefile: Do not build or assume librpc_compat_pic.
  * Makefile: Do not build libmesusage.
  * gen-as-const: Always add preamble.
  * [BOOTSTRAP_GLIBC]: Really disable rpc.

Upstream status: Not presented upstream.

diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/elf/Makefile glibc-2.16.0/elf/Makefile
--- /home/janneke/src/glibc-2.16.0/elf/Makefile	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/elf/Makefile	2018-09-02 12:54:44.616962543 +0200
@@ -17,6 +17,8 @@

 # Makefile for elf subdirectory of GNU C Library.

+SHELL := /bin/sh
+
 subdir		:= elf

 headers		= elf.h bits/elfclass.h link.h bits/link.h
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/include/libc-symbols.h glibc-2.16.0/include/libc-symbols.h
--- /home/janneke/src/glibc-2.16.0/include/libc-symbols.h	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/include/libc-symbols.h	2018-09-02 22:41:00.798467803 +0200
@@ -558,9 +558,9 @@ for linking")
 # define libc_hidden_weak(name) hidden_weak (name)
 # ifdef LINK_OBSOLETE_RPC
    /* libc_hidden_nolink_sunrpc should only get used in sunrpc code.  */
-#  define libc_hidden_nolink_sunrpc(name, version) hidden_def (name)
+#  define libc_hidden_nolink_sunrpc(name, version)
 # else
-#  define libc_hidden_nolink_sunrpc(name, version) hidden_nolink (name, libc, version)
+#  define libc_hidden_nolink_sunrpc(name, version)
 # endif
 # define libc_hidden_ver(local, name) hidden_ver (local, name)
 # define libc_hidden_data_def(name) hidden_data_def (name)
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/Makeconfig glibc-2.16.0/Makeconfig
--- /home/janneke/src/glibc-2.16.0/Makeconfig	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/Makeconfig	2018-09-03 00:00:25.290357414 +0200
@@ -23,6 +23,9 @@ ifneq (,)
 This makefile requires GNU Make.
 endif

+SHELL := /bin/sh
+export SHELL
+
 all: # Make this the default goal

 ifneq "$(origin +included-Makeconfig)" "file"
@@ -521,9 +524,9 @@ ifneq ($(have-cc-with-libunwind),yes)
 else
   libunwind = -lunwind
 endif
-libgcc_eh := -Wl,--as-needed -lgcc_s $(libunwind) -Wl,--no-as-needed
+libgcc_eh := #-Wl,--as-needed -lgcc_s $(libunwind) -Wl,--no-as-needed
 gnulib := -lgcc $(libgcc_eh)
-static-gnulib := -lgcc -lgcc_eh $(libunwind)
+static-gnulib := -lgcc $(libunwind)
 libc.so-gnulib := -lgcc
 endif
 +preinit = $(addprefix $(csu-objpfx),crti.o)
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/Makefile glibc-2.16.0/Makefile
--- /home/janneke/src/glibc-2.16.0/Makefile	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/Makefile	2018-09-02 23:01:10.485803965 +0200
@@ -22,6 +22,9 @@ ifneq (,)
 This makefile requires GNU Make.
 endif

+SHELL := /bin/sh
+export SHELL
+
 include Makeconfig

@@ -135,13 +138,10 @@ $(common-objpfx)linkobj/libc.so: $(elfob
 				 $(shlib-lds)
 	$(build-shlib)

-$(common-objpfx)linkobj/libc_pic.a: $(common-objpfx)libc_pic.a \
-				    $(common-objpfx)sunrpc/librpc_compat_pic.a
+$(common-objpfx)linkobj/libc_pic.a: $(common-objpfx)libc_pic.a
 	$(..)./scripts/mkinstalldirs $(common-objpfx)linkobj
 	(cd $(common-objpfx)linkobj; \
 	 $(AR) x ../libc_pic.a; \
-	 rm $$($(AR) t ../sunrpc/librpc_compat_pic.a | sed 's/^compat-//'); \
-	 $(AR) x ../sunrpc/librpc_compat_pic.a; \
 	 $(AR) cr libc_pic.a *.os; \
 	 rm *.os)
 endif
@@ -151,7 +151,7 @@ endif
 # the current libc build for testing.
 $(common-objpfx)testrun.sh: $(common-objpfx)config.make \
 			    $(..)Makeconfig $(..)Makefile
-	(echo '#!/bin/sh'; \
+	(echo '#! $(SHELL)'; \
 	 echo 'builddir=`dirname "$$0"`'; \
 	 echo 'GCONV_PATH="$${builddir}/iconvdata" \'; \
 	 echo 'exec $(subst $(common-objdir),"$${builddir}",\
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/Makefile.in glibc-2.16.0/Makefile.in
--- /home/janneke/src/glibc-2.16.0/Makefile.in	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/Makefile.in	2018-09-02 13:03:01.892962551 +0200
@@ -9,3 +9,6 @@ all .DEFAULT:
 install:
 	LANGUAGE=C LC_ALL=C; export LANGUAGE LC_ALL; \
 	$(MAKE) -r PARALLELMFLAGS="$(PARALLELMFLAGS)" -C $(srcdir) objdir=`pwd` $@
+
+export SHELL
+export BASH
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/malloc/Makefile glibc-2.16.0/malloc/Makefile
--- /home/janneke/src/glibc-2.16.0/malloc/Makefile	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/malloc/Makefile	2018-09-02 17:11:33.461547394 +0200
@@ -35,7 +35,7 @@ install-lib := libmcheck.a
 non-lib.a := libmcheck.a

 # Additional library.
-extra-libs = libmemusage
+extra-libs = #libmemusage
 extra-libs-others = $(extra-libs)

 libmemusage-routines = memusage
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/nscd/cache.c glibc-2.16.0/nscd/cache.c
--- /home/janneke/src/glibc-2.16.0/nscd/cache.c	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/nscd/cache.c	2018-09-02 23:38:31.757616750 +0200
@@ -74,7 +74,11 @@ struct datahead *
 cache_search (request_type type, const void *key, size_t len,
 	      struct database_dyn *table, uid_t owner)
 {
+#if !BOOTSTRAP_GLIBC
   unsigned long int hash = __nis_hash (key, len) % table->head->module;
+#else
+  unsigned long int hash = 0;
+#endif

   unsigned long int nsearched = 0;
   struct datahead *result = NULL;
@@ -153,7 +153,11 @@ cache_add (int type, const void *key, si
 	       first ? _(" (first)") : "");
     }

+#if !BOOTSTRAP_GLIBC
   unsigned long int hash = __nis_hash (key, len) % table->head->module;
+#else
+  unsigned long int hash = 0;
+#endif
   struct hashentry *newp;

   newp = mempool_alloc (table, sizeof (struct hashentry), 0);
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/nscd/Makefile glibc-2.16.0/nscd/Makefile
--- /home/janneke/src/glibc-2.16.0/nscd/Makefile	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/nscd/Makefile	2018-09-02 23:49:29.948031787 +0200
@@ -126,9 +126,7 @@ include $(patsubst %,$(..)cppflags-itera
 $(objpfx)nscd: $(nscd-modules:%=$(objpfx)%.o)

 ifeq ($(build-shared),yes)
-$(objpfx)nscd: $(common-objpfx)rt/librt.so $(shared-thread-library) \
-	       $(common-objpfx)nis/libnsl.so
+$(objpfx)nscd: $(common-objpfx)rt/librt.so $(shared-thread-library)
 else
-$(objpfx)nscd: $(common-objpfx)rt/librt.a $(static-thread-library) \
-	       $(common-objpfx)nis/libnsl.a
+$(objpfx)nscd: $(common-objpfx)rt/librt.a $(static-thread-library)
 endif
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/nscd/nscd_helper.c glibc-2.16.0/nscd/nscd_helper.c
--- /home/janneke/src/glibc-2.16.0/nscd/nscd_helper.c	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/nscd/nscd_helper.c	2018-09-02 23:38:04.941189464 +0200
@@ -474,7 +474,7 @@ struct datahead *
 __nscd_cache_search (request_type type, const char *key, size_t keylen,
 		     const struct mapped_database *mapped, size_t datalen)
 {
-  unsigned long int hash = __nis_hash (key, keylen) % mapped->head->module;
+  unsigned long int hash = 0;
   size_t datasize = mapped->datasize;

   ref_t trail = mapped->head->array[hash];
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/nss/getent.c glibc-2.16.0/nss/getent.c
--- /home/janneke/src/glibc-2.16.0/nss/function.def	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/nss/function.def	2018-09-18 13:54:49.582060539 +0200
@@ -63,10 +63,12 @@
 DEFINE_GET (files, pwnam)
 DEFINE_GET (files, pwuid)

+#if !BOOTSTRAP_GLIBC
 /* rpc */
 DEFINE_ENT (files, rpc)
 DEFINE_GETBY (files, rpc, name)
 DEFINE_GETBY (files, rpc, number)
+#endif

 /* services */
 DEFINE_ENT (files, serv)
diff -u ~/src/glibc-2.16.0/nss/getent.c glibc-2.16.0/nss/getent.c
--- /home/janneke/src/glibc-2.16.0/nss/getent.c	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/nss/getent.c	2018-09-18 13:57:41.856849140 +0200
@@ -700,6 +700,7 @@
   return result;
 }

+#if !BOOTSTRAP_GLIBC
 /* Now is all for rpc */
 static inline void
 print_rpc (struct rpcent *rpc)
@@ -745,6 +746,7 @@

   return result;
 }
+#endif //rpc

 /* for services */
 static void
@@ -880,7 +882,9 @@
 D(networks)
 D(passwd)
 D(protocols)
+#if !BOOTSTRAP_GLIBC
 D(rpc)
+#endif
 D(services)
 D(shadow)
 #undef D
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/resolv/netdb.h glibc-2.16.0/resolv/netdb.h
--- /home/janneke/src/glibc-2.16.0/resolv/netdb.h	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/resolv/netdb.h	2018-09-08 08:49:30.537811219 +0200
@@ -26,11 +26,13 @@

 #include <netinet/in.h>
 #include <stdint.h>
+#if 0 //!BOOTSTRAP_GLIBC
 #ifdef __USE_MISC
 /* This is necessary to make this include file properly replace the
    Sun version.  */
 # include <rpc/netdb.h>
 #endif
+#endif

 #ifdef __USE_GNU
 # define __need_sigevent_t
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/Rules glibc-2.16.0/Rules
--- /home/janneke/src/glibc-2.16.0/Rules	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/Rules	2018-09-02 10:52:06.927362861 +0200
@@ -24,6 +24,9 @@ ifneq (,)
 This makefile requires GNU Make.
 endif

+export SHELL
+export BASH
+
 all: # Don't let the default goal come from Makeconfig.

 include $(firstword $(..) ../)Makeconfig
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/scripts/gen-as-const.awk glibc-2.16.0/scripts/gen-as-const.awk
--- /home/janneke/src/glibc-2.16.0/scripts/gen-as-const.awk	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/scripts/gen-as-const.awk	2018-09-01 18:08:37.266516330 +0200
@@ -14,6 +14,12 @@ BEGIN { started = 0 }

 NF >= 1 && !started {
   if (test) {
+    print "\n#include <stddef.h>";
+    print "\n#include <stdint.h>";
+#    print "\ntypedef unsigned long size_t;";
+    print "\n#ifndef offsetof";
+    print "\n#define offsetof(type, field) ((size_t)&((type *)0)->field)";
+    print "\n#endif";
     print "\n#include <inttypes.h>";
     print "\n#include <stdio.h>";
     print "\n#include <bits/wordsize.h>";
@@ -33,8 +39,15 @@ NF >= 1 && !started {
       " source, #name, U (asconst_##name), #expr, (c_t) (expr));" \
       " } else ++good;\n";
   }
-  else
+  else {
+    print "\n#include <stddef.h>";
+    print "\n#include <stdint.h>";
+#    print "\ntypedef unsigned long size_t;";
+    print "\n#ifndef offsetof";
+    print "\n#define offsetof(type, field) ((size_t)&((type *)0)->field)";
+    print "\n#endif";
     print "void dummy(void) {";
+  }
   started = 1;
 }

diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/sunrpc/auth_none.c glibc-2.16.0/sunrpc/auth_none.c
--- /home/janneke/src/glibc-2.16.0/sunrpc/auth_none.c	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/sunrpc/auth_none.c	2018-09-02 22:09:21.629007932 +0200
@@ -95,7 +95,9 @@ authnone_create (void)
   __libc_once (authnone_private_guard, authnone_create_once);
   return &authnone_private.no_client;
 }
+#if !BOOTSTRAP_GLIBC
 libc_hidden_nolink_sunrpc (authnone_create, GLIBC_2_0)
+#endif

 static bool_t
 authnone_marshal (AUTH *client, XDR *xdrs)
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/sunrpc/authuxprot.c glibc-2.16.0/sunrpc/authuxprot.c
--- /home/janneke/src/glibc-2.16.0/sunrpc/authuxprot.c	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/sunrpc/authuxprot.c	2018-09-02 22:15:51.927158451 +0200
@@ -63,4 +63,6 @@ xdr_authunix_parms (XDR * xdrs, struct a
     }
   return FALSE;
 }
+#if !BOOTSTRAP_GLIBC
 libc_hidden_nolink_sunrpc (xdr_authunix_parms, GLIBC_2_0)
+#endif
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/sunrpc/bindrsvprt.c glibc-2.16.0/sunrpc/bindrsvprt.c
--- /home/janneke/src/glibc-2.16.0/sunrpc/bindrsvprt.c	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/sunrpc/bindrsvprt.c	2018-09-02 22:24:32.687187675 +0200
@@ -96,4 +96,7 @@ bindresvport (int sd, struct sockaddr_in

   return res;
 }
+#if !BOOTSTRAP_GLIBC
 libc_hidden_def (bindresvport)
+#endif
+
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/sunrpc/clnt_raw.c glibc-2.16.0/sunrpc/clnt_raw.c
--- /home/janneke/src/glibc-2.16.0/sunrpc/clnt_raw.c	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/sunrpc/clnt_raw.c	2018-09-02 22:33:21.151343826 +0200
@@ -40,6 +40,7 @@
 #include <rpc/svc.h>
 #include <rpc/xdr.h>
 #include <libintl.h>
+#include <stddef.h>

 #define MCALL_MSG_SIZE 24

@@ -129,7 +130,9 @@ clntraw_create (u_long prog, u_long vers
   client->cl_auth = authnone_create ();
   return client;
 }
+#if !BOOTSTRAP_GLIBC
 libc_hidden_nolink_sunrpc (clntraw_create, GLIBC_2_0)
+#endif

 static enum clnt_stat
 clntraw_call (h, proc, xargs, argsp, xresults, resultsp, timeout)
diff '--exclude=*.orig' -purN /home/janneke/src/glibc-2.16.0/sunrpc/clnt_simp.c glibc-2.16.0/sunrpc/clnt_simp.c
--- /home/janneke/src/glibc-2.16.0/sunrpc/clnt_simp.c	2012-06-30 21:12:34.000000000 +0200
+++ glibc-2.16.0/sunrpc/clnt_simp.c	2018-09-02 22:34:14.884175251 +0200
@@ -139,7 +139,9 @@ callrpc (const char *host, u_long prognu
     crp->valid = 0;
   return (int) clnt_stat;
 }
+#if !BOOTSTRAP_GLIBC
 libc_hidden_nolink_sunrpc (callrpc, GLIBC_2_0)
+#endif

 #ifdef _RPC_THREAD_SAFE_
 void


code:
This patch enables building glibc-2.2.5 using TCC and GNU Make 4.x and Mes C Library.

  * Makefile: Do not assemble from stdin, use file indirection.
  * Makefile: Add new target: install-lib-all.
  * Makefile: Avoid building stub DOC.
  * [_LIBC_REENTRANT]: Add missing guarding.
  * [MES_BOOTSTRAP]: Disable some GCC extensions.
  * [MES_BOOTSTRAP]: Add missing GCC div/mod defines.

Upstream status: Not presented upstream.

diff -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/config.h.in glibc-2.2.5/config.h.in
--- ../glibc-2.2.5/config.h.in	2001-11-16 02:02:56.000000000 +0100
+++ glibc-2.2.5/config.h.in	2018-06-17 21:30:02.313029074 +0200
@@ -1,3 +1,10 @@
+#if MES_BOOTSTRAP && BOOTSTRAP_GLIBC
+#undef __umoddi3
+#define __umoddi3(a,b) ((a)%(b))
+#undef __udivdi3
+#define __udivdi3(a,b) ((a)/(b))
+#endif
+
 #if !defined ASSEMBLER && !defined _ISOMAC && !defined __OPTIMIZE__
 # error "glibc cannot be compiled without optimization"
 #endif
diff -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/configure glibc-2.2.5/configure
--- ../glibc-2.2.5/configure	2002-01-08 23:16:44.000000000 +0100
+++ glibc-2.2.5/configure	2018-06-07 20:47:26.608895319 +0200
@@ -1530,7 +1530,7 @@ echo "configure:1530: checking version o
   ac_prog_version=`$MAKE --version 2>&1 | sed -n 's/^.*GNU Make[^0-9]*\([0-9][0-9.]*\).*$/\1/p'`
   case $ac_prog_version in
     '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
-    3.79* | 3.[89]*)
+    3.79* | 3.[89]* | 4.*)
        ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
     *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;

diff -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/Makeconfig glibc-2.2.5/Makeconfig
--- ../glibc-2.2.5/Makeconfig	2001-09-12 20:49:45.000000000 +0200
+++ glibc-2.2.5/Makeconfig	2018-06-20 16:33:35.472167202 +0200
@@ -400,7 +400,7 @@ ifndef +link
 						     $(start-installed-name))\
 			   $(+preinit) $(link-extra-libs) \
 			   $(common-objpfx)libc% $(+postinit),$^) \
-	      $(link-extra-libs) $(link-libc) $(+postctor) $(+postinit)
+	      $(link-extra-libs) $(link-libc) $(+postctor) $(+postinit) -lc -lgcc2
 endif
 # Command for statically linking programs with the C library.
 ifndef +link-static
@@ -412,7 +412,7 @@ ifndef +link-static
 						     $(start-installed-name))\
 			   $(+preinit) $(link-extra-libs-static) \
 			   $(common-objpfx)libc% $(+postinit),$^) \
-	      $(link-extra-libs-static) $(link-libc-static) $(+postctor) $(+postinit)
+	      $(link-extra-libs-static) $(link-libc-static) $(+postctor) $(+postinit) -lc -lgcc2
 endif
 # Command for statically linking bounded-pointer programs with the C library.
 ifndef +link-bounded
@@ -424,7 +424,7 @@ ifndef +link-bounded
 						     $(start-installed-name))\
 			   $(+preinit) $(link-extra-libs-bounded) \
 			   $(common-objpfx)libc% $(+postinit),$^) \
-	      $(link-extra-libs-bounded) $(link-libc-bounded) $(+postctor) $(+postinit)
+	      $(link-extra-libs-bounded) $(link-libc-bounded) $(+postctor) $(+postinit) -lc -lgcc2
 endif
 ifndef config-LDFLAGS
 ifeq (yesyes,$(build-shared)$(elf))
diff -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/Makerules glibc-2.2.5/Makerules
--- ../glibc-2.2.5/Makerules	2001-11-16 02:02:19.000000000 +0100
+++ glibc-2.2.5/Makerules	2018-06-10 15:03:42.390329860 +0200
@@ -748,6 +748,18 @@ endef
 installed-libcs := $(foreach o,$(filter-out .os,$(object-suffixes-for-libc)),\
 			     $(inst_libdir)/$(patsubst %,$(libtype$o),\
 						     $(libprefix)$(libc-name)))
+
+ifeq (yes,$(build-shared))
+install-lib-all: $(inst_libdir)/libc.a \
+                $(inst_slibdir)/libc.so$(libc.so-version) \
+		$(inst_slibdir)/libc-$(version).so \
+		$(inst_libdir)/libc.so \
+	install-lib
+else
+install-lib-all: $(inst_libdir)/libc.a \
+	install-lib
+endif
+
 install: $(installed-libcs)
 $(installed-libcs): $(inst_libdir)/lib$(libprefix)%: lib $(+force)
 	$(make-target-directory)
diff -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/misc/syslog.c glibc-2.2.5/misc/syslog.c
--- ../glibc-2.2.5/misc/syslog.c	2001-08-31 01:13:49.000000000 +0200
+++ glibc-2.2.5/misc/syslog.c	2018-06-09 09:01:20.008918690 +0200
@@ -216,9 +216,11 @@ vsyslog(pri, fmt, ap)

 	/* Prepare for multiple users.  We have to take care: open and
 	   write are cancellation points.  */
+#if _LIBC_REENTRANT
 	__libc_cleanup_region_start (1, (void (*) (void *)) cancel_handler,
 				     &oldaction_ptr);
 	__libc_lock_lock (syslog_lock);
+#endif

 	/* Prepare for a broken connection.  */
  	memset (&action, 0, sizeof (action));
@@ -268,9 +270,11 @@ vsyslog(pri, fmt, ap)
 	if (sigpipe == 0)
 		__sigaction (SIGPIPE, &oldaction, (struct sigaction *) NULL);

+#if _LIBC_REENTRANT
 	/* End of critical section.  */
 	__libc_cleanup_region_end (0);
 	__libc_lock_unlock (syslog_lock);
+#endif

 	free (buf);
 }
@@ -326,16 +330,20 @@ openlog_internal(const char *ident, int
 void
 openlog (const char *ident, int logstat, int logfac)
 {
+#if _LIBC_REENTRANT
   /* Protect against multiple users.  */
   __libc_cleanup_region_start (1,
 			       (void (*) __P ((void *))) __libc_mutex_unlock,
 			       &syslog_lock);
   __libc_lock_lock (syslog_lock);
+#endif

   openlog_internal (ident, logstat, logfac);

+#if _LIBC_REENTRANT
   /* Free the lock.  */
   __libc_cleanup_region_end (1);
+#endif
 }

 static void
@@ -358,18 +366,22 @@ closelog_internal()
 void
 closelog ()
 {
+#if _LIBC_REENTRANT
   /* Protect against multiple users.  */
   __libc_cleanup_region_start (1,
 			       (void (*) __P ((void *))) __libc_mutex_unlock,
 			       &syslog_lock);
   __libc_lock_lock (syslog_lock);
+#endif

   closelog_internal ();
   LogTag = NULL;
   LogType = SOCK_DGRAM; /* this is the default */

+#if _LIBC_REENTRANT
   /* Free the lock.  */
   __libc_cleanup_region_end (1);
+#endif
 }

 #ifdef _LIBC_REENTRANT
diff -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/Rules glibc-2.2.5/Rules
--- ../glibc-2.2.5/Rules	2001-08-30 00:44:35.000000000 +0200
+++ glibc-2.2.5/Rules	2018-06-09 08:15:54.880683675 +0200
@@ -218,7 +218,7 @@ endif
 	fopen_max=`sed -n 's/^#define OPEN_MAX //1p' $(@:st=hT)`; 	\
 	filename_max=`sed -n 's/^#define PATH_MAX //1p' $(@:st=hT)`;	\
 	iov_max=`sed -n 's/^#define UIO_MAXIOV //p' $(@:st=hT)`;	\
-	fopen_max=$${fopen_max:-16};					\
+	fopen_max=$${fu_fopen_max:-16};					\
 	filename_max=$${filename_max:-1024};				\
 	if [ -z $$iov_max ]; then					\
 	  define_iov_max="# undef IOV_MAX";				\
diff -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/stdio-common/perror.c glibc-2.2.5/stdio-common/perror.c
--- ../glibc-2.2.5/stdio-common/perror.c	2001-09-01 07:33:01.000000000 +0200
+++ glibc-2.2.5/stdio-common/perror.c	2018-06-09 10:42:25.909899529 +0200
@@ -48,6 +48,9 @@ perror_internal (FILE *fp, const char *s
 }

+#if MES_BOOTSTRAP
+#define fileno_unlocked(x) 1
+#endif
 /* Print a line on stderr consisting of the text in S, a colon, a space,
    a message describing the meaning of the contents of `errno' and a newline.
    If S is NULL or "", the colon and space are omitted.  */
diff -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/sysdeps/i386/fpu/ftestexcept.c glibc-2.2.5/sysdeps/i386/fpu/ftestexcept.c
--- ../glibc-2.2.5/sysdeps/i386/fpu/ftestexcept.c	2001-07-06 06:55:53.000000000 +0200
+++ glibc-2.2.5/sysdeps/i386/fpu/ftestexcept.c	2018-06-09 09:45:13.363031424 +0200
@@ -25,8 +25,10 @@ fetestexcept (int excepts)
 {
   int temp;

+#if !MES_BOOTSTRAP
   /* Get current exceptions.  */
   __asm__ ("fnstsw %0" : "=a" (temp));
+#endif

   return temp & excepts & FE_ALL_EXCEPT;
 }
diff -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/sysdeps/unix/make-syscalls.sh glibc-2.2.5/sysdeps/unix/make-syscalls.sh
--- ../glibc-2.2.5/sysdeps/unix/make-syscalls.sh	2001-09-13 00:19:30.000000000 +0200
+++ glibc-2.2.5/sysdeps/unix/make-syscalls.sh	2018-06-20 15:16:01.813004453 +0200
@@ -173,7 +173,7 @@ shared-only-routines += $file
   done

   # And finally, pipe this all into the compiler.
-  echo '	) | $(COMPILE.S) -x assembler-with-cpp -o $@ -'
+  echo '	) > stdin.c; $(COMPILE.S) -x assembler-with-cpp -o $@ stdin.c'

   case $weak in
   *@*)
@@ -284,7 +284,7 @@ shared-only-routines += $file
     echo "\
 	 echo ''; \\
 	 echo '#include <bp-thunks.h>'; \\
-	) | \$(COMPILE.c) -x c -o \$@ -"
+	) > stdin.c; \$(COMPILE.c) -x c -o \$@ stdin.c"
 ### Use this for debugging intermediate output:
 ### 	) >\$(@:.ob=.c)
 ### 	\$(subst -c,-E,\$(COMPILE.c)) -o \$(@:.ob=.ib) \$(@:.ob=.c)
diff -purN -x .git -x fubar -x fubar.c -x Makefile -x config.status -x config.h -x BOOT -x BOOT-GCC -x texis -x '*.info*' ../glibc-2.2.5/sysdeps/unix/sysv/linux/sys/timex.h glibc-2.2.5/sysdeps/unix/sysv/linux/sys/timex.h
--- ../glibc-2.2.5/sysdeps/unix/sysv/linux/sys/timex.h	2001-07-06 06:56:21.000000000 +0200
+++ glibc-2.2.5/sysdeps/unix/sysv/linux/sys/timex.h	2018-06-09 20:09:07.713806647 +0200
@@ -54,10 +54,12 @@ struct timex
   long int errcnt;	/* calibration errors (ro) */
   long int stbcnt;	/* stability limit exceeded (ro) */

+#if !MES_BOOTSTRAP
   /* ??? */
   int  :32; int  :32; int  :32; int  :32;
   int  :32; int  :32; int  :32; int  :32;
   int  :32; int  :32; int  :32; int  :32;
+#endif
 };

 /* Mode codes (timex.mode) */
--- ../glibc-2.2.5/manual/Makefile	2001-08-28 10:05:40.000000000 +0200
+++ glibc-2.2.5/manual/Makefile	2018-06-09 10:13:03.093633660 +0200
@@ -247,7 +247,11 @@
 .PHONY: stubs
 stubs: $(objpfx)stubs
 endif
-$(objpfx)stubs ../po/manual.pot $(objpfx)stamp%:
+po/manual.pot $(objpfx)stubs:
+	$(make-target-directory)
+	touch $@
+
+$(objpfx)stamp%:
 	$(make-target-directory)
 	touch $@


code:
We want to allow builds in chroots that lack /bin/sh.  Thus, system(3)
and popen(3) need to be tweaked to use the right shell.  For the bootstrap
glibc, we just use whatever `sh' can be found in $PATH.  The final glibc
instead uses the hard-coded absolute file name of `bash'.

--- a/sysdeps/posix/system.c
+++ b/sysdeps/posix/system.c
@@ -134,7 +134,7 @@ do_system (const char *line)
       INIT_LOCK ();

       /* Exec the shell.  */
-      (void) __execve (SHELL_PATH, (char *const *) new_argv, __environ);
+      (void) __execvpe (SHELL_NAME, (char *const *) new_argv, __environ);
       _exit (127);
     }
   else if (pid < (pid_t) 0)

--- a/libio/iopopen.c
+++ b/libio/iopopen.c
@@ -145,7 +145,7 @@ _IO_new_proc_open (fp, command, mode)
 	    _IO_close (fd);
 	}

-      _IO_execl ("/bin/sh", "sh", "-c", command, (char *) 0);
+      execlp ("sh", "sh", "-c", command, (char *) 0);
       _IO__exit (127);
     }
   _IO_close (child_end);


code:
We want to allow builds in chroots that lack /bin/sh.  Thus, system(3)
and popen(3) need to be tweaked to use the right shell.  For the bootstrap
glibc, we just use whatever `sh' can be found in $PATH.  The final glibc
instead uses the hard-coded absolute file name of `bash'.

--- a/sysdeps/posix/system.c
+++ b/sysdeps/posix/system.c
@@ -106,8 +106,8 @@ do_system (const char *line)
       (void) UNBLOCK;

       /* Exec the shell.  */
-      (void) __execve (SHELL_PATH, (char *const *) new_argv, __environ);
+      (void) execvp (SHELL_NAME, (char *const *) new_argv);
       _exit (127);
     }
   else if (pid < (pid_t) 0)
     /* The fork failed.  */
--- a/libio/iopopen.c
+++ b/libio/iopopen.c
@@ -170,7 +170,7 @@ _IO_new_proc_open (fp, command, mode)
       for (p = proc_file_chain; p; p = p->next)
 	_IO_close (_IO_fileno ((_IO_FILE *) p));

-      _IO_execl ("/bin/sh", "sh", "-c", command, (char *) 0);
+      execlp ("sh", "sh", "-c", command, (char *) 0);
       _IO__exit (127);
     }
   _IO_close (child_end);


code:
We want to allow builds in chroots that lack /bin/sh.  Thus, system(3)
and popen(3) need to be tweaked to use the right shell.  For the bootstrap
glibc, we just use whatever `sh' can be found in $PATH.  The final glibc
instead uses the hard-coded absolute file name of `bash'.

--- a/sysdeps/posix/system.c
+++ b/sysdeps/posix/system.c
@@ -140,7 +140,7 @@ do_system (const char *line)
   __posix_spawnattr_setflags (&spawn_attr,
 			      POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK);

-  status = __posix_spawn (&pid, SHELL_PATH, 0, &spawn_attr,
+  status = __posix_spawnp (&pid, SHELL_NAME, 0, &spawn_attr,
 			  (char *const[]){ (char*) SHELL_NAME,
 					   (char*) "-c",
 					   (char *) line, NULL },
--- a/libio/iopopen.c
+++ b/libio/iopopen.c
@@ -85,7 +85,7 @@ spawn_process (posix_spawn_file_actions_t *fa, FILE *fp, const char *command,
 	return false;
     }

-  if (__posix_spawn (&((_IO_proc_file *) fp)->pid, _PATH_BSHELL, fa, 0,
+  if (__posix_spawnp (&((_IO_proc_file *) fp)->pid, "sh", fa, 0,
 		     (char *const[]){ (char*) "sh", (char*) "-c",
 		     (char *) command, NULL }, __environ) != 0)
     return false;

--- a/include/spawn.h
+++ b/include/spawn.h
@@ -5,6 +5,9 @@
 __typeof (posix_spawn) __posix_spawn;
 libc_hidden_proto (__posix_spawn)

+__typeof (posix_spawnp) __posix_spawnp;
+libc_hidden_proto (__posix_spawnp)
+
 __typeof (posix_spawn_file_actions_addclose)
   __posix_spawn_file_actions_addclose attribute_hidden;

--- a/posix/spawnp.c
+++ b/posix/spawnp.c
@@ -31,6 +31,7 @@ __posix_spawnp (pid_t *pid, const char *file,
                   SPAWN_XFLAGS_USE_PATH);
 }
 versioned_symbol (libc, __posix_spawnp, posix_spawnp, GLIBC_2_15);
+libc_hidden_def (__posix_spawnp)

 #if SHLIB_COMPAT (libc, GLIBC_2_2, GLIBC_2_15)


code:
Fix a regression in glibc 2.27 when built without ldconfig.  See
<https://sourceware.org/bugzilla/show_bug.cgi?id=22977> for details.

diff --git a/include/libc-symbols.h b/include/libc-symbols.h
index 6137304b0b..7d630f36d8 100644
--- a/include/libc-symbols.h
+++ b/include/libc-symbols.h
@@ -508,7 +508,7 @@ for linking")
 # ifndef __ASSEMBLER__
 #  if !defined SHARED && IS_IN (libc) && !defined LIBC_NONSHARED \
       && (!defined PIC || !defined NO_HIDDEN_EXTERN_FUNC_IN_PIE) \
-      && !defined NO_HIDDEN
+      && !defined NO_HIDDEN && defined USE_LDCONFIG
 #   define __hidden_proto_hiddenattr(attrs...) \
   __attribute__ ((visibility ("hidden"), ##attrs))
 #   define hidden_proto(name, attrs...) \


code:
This is needed to run Python on the Hurd, especially during the build of
python-boot0.

Adapted from https://salsa.debian.org/glibc-team/glibc/-/blob/glibc-2.31/debian/patches/hurd-i386/unsubmitted-clock_t_centiseconds.diff

Use the realtime clock for the monotonic clock. This is of course not a proper
implementation (which is being done in Mach), but will permit to fix at least
the iceweasel stack.

vlc however doesn't build when _POSIX_CLOCK_SELECTION is enabled but
_POSIX_TIMERS is not, and they refuse to fix that (see #765578), so disable the
former.

From 0aa1dfd580cf9ad7b812c307b128decb782b825f Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Mon, 2 Mar 2020 18:59:04 +0100
Subject: [PATCH 2/2] Use realtime clock for the monotonic clock.

---
 sysdeps/mach/clock_gettime.c       | 2 +-
 sysdeps/mach/hurd/bits/posix_opt.h | 6 +++---
 sysdeps/posix/clock_getres.c       | 1 +
 sysdeps/pthread/timer_create.c     | 2 +-
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/sysdeps/mach/clock_gettime.c b/sysdeps/mach/clock_gettime.c
index ac3547df3c..af8681ba4e 100644
--- a/sysdeps/mach/clock_gettime.c
+++ b/sysdeps/mach/clock_gettime.c
@@ -25,7 +25,7 @@
 int
 __clock_gettime (clockid_t clock_id, struct timespec *ts)
 {
-  if (clock_id != CLOCK_REALTIME)
+  if (clock_id != CLOCK_MONOTONIC && clock_id != CLOCK_REALTIME)
     {
       errno = EINVAL;
       return -1;
diff --git a/sysdeps/mach/hurd/bits/posix_opt.h b/sysdeps/mach/hurd/bits/posix_opt.h
index 0050151332..27b3a28ab7 100644
--- a/sysdeps/mach/hurd/bits/posix_opt.h
+++ b/sysdeps/mach/hurd/bits/posix_opt.h
@@ -163,10 +163,10 @@
 #define _POSIX_THREAD_PROCESS_SHARED	-1

 /* The monotonic clock might be available.  */
-#define _POSIX_MONOTONIC_CLOCK	0
+#define _POSIX_MONOTONIC_CLOCK	200809L

-/* The clock selection interfaces are available.  */
-#define _POSIX_CLOCK_SELECTION	200809L
+/* The clock selection interfaces are not really available yet.  */
+#define _POSIX_CLOCK_SELECTION	-1

 /* Advisory information interfaces could be available in future.  */
 #define _POSIX_ADVISORY_INFO	0
diff --git a/sysdeps/posix/clock_getres.c b/sysdeps/posix/clock_getres.c
index fcd79fd554..1dd02aa449 100644
--- a/sysdeps/posix/clock_getres.c
+++ b/sysdeps/posix/clock_getres.c
@@ -52,6 +52,7 @@ __clock_getres (clockid_t clock_id, struct timespec *res)
   switch (clock_id)
     {
     case CLOCK_REALTIME:
+    case CLOCK_MONOTONIC:
       retval = realtime_getres (res);
       break;

diff --git a/sysdeps/pthread/timer_create.c b/sysdeps/pthread/timer_create.c
index 9d8a9ea8ae..3430582c09 100644
--- a/sysdeps/pthread/timer_create.c
+++ b/sysdeps/pthread/timer_create.c
@@ -48,7 +48,7 @@ timer_create (clockid_t clock_id, struct sigevent *evp, timer_t *timerid)
       return -1;
     }

-  if (clock_id != CLOCK_REALTIME)
+  if (clock_id != CLOCK_REALTIME && clock_id != CLOCK_MONOTONIC)
     {
       __set_errno (EINVAL);
       return -1;
--
2.24.0


code:
This is needed to run Python on the Hurd, especially during the build of
python-boot0.

Adapted from https://salsa.debian.org/glibc-team/glibc/-/blob/glibc-2.31/debian/patches/hurd-i386/unsubmitted-clock_t_centiseconds.diff

    commit d57f2f9b4bd007846af2fb4217486ea572579010
    Author: Richard Braun <rbraun@sceen.net>
    Date:   Tue Aug 27 11:35:31 2013 +0200

        Express CPU time (clock_t of times(2)) in centiseconds

From 170c292b643fdc1eb56881e6592b07c0c019993e Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Mon, 2 Mar 2020 18:28:54 +0100
Subject: [PATCH 1/2] Express CPU time (clock_t) in centiseconds

---
 sysdeps/mach/hurd/clock.c     | 8 ++++----
 sysdeps/mach/hurd/getclktck.c | 5 ++---
 sysdeps/mach/hurd/setitimer.c | 2 +-
 sysdeps/mach/hurd/times.c     | 2 +-
 4 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/sysdeps/mach/hurd/clock.c b/sysdeps/mach/hurd/clock.c
index 7cb42df786..4db49b579d 100644
--- a/sysdeps/mach/hurd/clock.c
+++ b/sysdeps/mach/hurd/clock.c
@@ -44,10 +44,10 @@ clock (void)
   if (err)
     return __hurd_fail (err);

-  total = bi.user_time.seconds * 1000000 + bi.user_time.microseconds;
-  total += tti.user_time.seconds * 1000000 + tti.user_time.microseconds;
-  total += bi.system_time.seconds * 1000000 + bi.system_time.microseconds;
-  total += tti.system_time.seconds * 1000000 + tti.system_time.microseconds;
+  total = bi.user_time.seconds * 100 + bi.user_time.microseconds / 10000;
+  total += tti.user_time.seconds * 100 + tti.user_time.microseconds / 10000;
+  total += bi.system_time.seconds * 100 + bi.system_time.microseconds / 10000;
+  total += tti.system_time.seconds * 100 + tti.system_time.microseconds / 10000;

   return total;
 }
diff --git a/sysdeps/mach/hurd/getclktck.c b/sysdeps/mach/hurd/getclktck.c
index 943e36e805..5a3cf0930b 100644
--- a/sysdeps/mach/hurd/getclktck.c
+++ b/sysdeps/mach/hurd/getclktck.c
@@ -18,12 +18,11 @@

 #include <time.h>

-/* Return frequency of `times'.
-   Since Mach reports CPU times in microseconds, we always use 1 million.  */
+/* Return frequency of `times'.  */
 int
 __getclktck (void)
 {
-  return 1000000;
+  return 100;
 }

 /* Before glibc 2.2, the Hurd actually did this differently, so we
diff --git a/sysdeps/mach/hurd/setitimer.c b/sysdeps/mach/hurd/setitimer.c
index b16f4ddd5d..8bf1464830 100644
--- a/sysdeps/mach/hurd/setitimer.c
+++ b/sysdeps/mach/hurd/setitimer.c
@@ -43,7 +43,7 @@ quantize_timeval (struct timeval *tv)
   static time_t quantum = -1;

   if (quantum == -1)
-    quantum = 1000000 / __getclktck ();
+    quantum = 100 / __getclktck ();

   tv->tv_usec = ((tv->tv_usec + (quantum - 1)) / quantum) * quantum;
   if (tv->tv_usec >= 1000000)
diff --git a/sysdeps/mach/hurd/times.c b/sysdeps/mach/hurd/times.c
index 23ed992783..cbf6039b19 100644
--- a/sysdeps/mach/hurd/times.c
+++ b/sysdeps/mach/hurd/times.c
@@ -29,7 +29,7 @@
 static inline clock_t
 clock_from_time_value (const time_value_t *t)
 {
-  return t->seconds * 1000000 + t->microseconds;
+  return t->seconds * 100 + t->microseconds / 10000;
 }

 /* Store the CPU time used by this process and all its
--
2.24.0


code:
From d6d2caef3e44d0713bb6625f697a1ec615abae70 Mon Sep 17 00:00:00 2001
From: "Jan (janneke) Nieuwenhuizen" <janneke@gnu.org>
Date: Sun, 5 Apr 2020 16:29:54 +0200
Subject: [PATCH 4/4] misc: Choose a longer arbitrary line length.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This allows running specifying a `getty' in the GNU Guix store.

* misc/getttyent.c (MAXLINELENGTH): Use 512 (instead of 100) as
another "great" arbitrary limit.

Co-Authored-By: Ludovic Courtès <ludo@gnu.org>
---
 misc/getttyent.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/misc/getttyent.c b/misc/getttyent.c
index 92d92b026f..508d296291 100644
--- a/misc/getttyent.c
+++ b/misc/getttyent.c
@@ -66,7 +66,7 @@ __getttyent (void)
 	static struct ttyent tty;
 	int c;
 	char *p;
-#define	MAXLINELENGTH	100
+#define	MAXLINELENGTH	512
 	static char line[MAXLINELENGTH];

 	if (!tf && !__setttyent())
--
2.26.0


code:
Provide a 'mach_print' symbol in libc.

--- a/sysdeps/mach/hurd/i386/libc.abilist	2020-04-01 19:22:44.710088821 +0200
+++ b/sysdeps/mach/hurd/i386/libc.abilist	2020-04-01 19:22:52.062051161 +0200
@@ -338,6 +338,7 @@
 GLIBC_2.2.6 __mach_port_allocate F
 GLIBC_2.2.6 __mach_port_deallocate F
 GLIBC_2.2.6 __mach_port_insert_right F
+GLIBC_2.21 __mach_print F
 GLIBC_2.2.6 __mach_reply_port F
 GLIBC_2.2.6 __mach_task_self_ D 0x4
 GLIBC_2.2.6 __mach_thread_self F

--- a/mach/Versions
+++ b/mach/Versions
@@ -56,6 +56,7 @@
   }
   GLIBC_2.21 {
     __mach_host_self_;
+    mach_print;
   }

   HURD_CTHREADS_0.3 {


code:
This patch implements "magic" lookup for "pid/…", as used when looking up
/proc/self.

The patch comes from the 't/magic-pid' branch
at <https://git.savannah.gnu.org/cgit/hurd/glibc.git>.  It squashes
commit 392e52286a302ca6157fbd221295e64ab6b6d8ba (by Justus Winter)
and commit 392e52286a302ca6157fbd221295e64ab6b6d8ba (a subsequent fix by
Samuel Thibault).

From: Justus Winter <4winter@informatik.uni-hamburg.de>
Subject: [PATCH] hurd: Handle `pid' magical lookup retry

        * hurd/lookup-retry.c: Handle `pid' magical lookup
        retry.

diff --git a/hurd/lookup-retry.c b/hurd/lookup-retry.c
index aee2ba8f93..6ed8de1653 100644
--- a/hurd/lookup-retry.c
+++ b/hurd/lookup-retry.c
@@ -25,6 +25,7 @@
 #include <string.h>
 #include <_itoa.h>
 #include <eloop-threshold.h>
+#include <unistd.h>

 /* Translate the error from dir_lookup into the error the user sees.  */
 static inline error_t
@@ -59,6 +60,7 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
   error_t err;
   char *file_name;
   int nloops;
+  file_t lastdir = MACH_PORT_NULL;

   error_t lookup_op (file_t startdir)
     {
@@ -107,14 +109,15 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
 	{
 	case FS_RETRY_REAUTH:
 	  if (err = reauthenticate (*result))
-	    return err;
+	    goto out;
 	  /* Fall through.  */

 	case FS_RETRY_NORMAL:
 	  if (nloops++ >= __eloop_threshold ())
 	    {
 	      __mach_port_deallocate (__mach_task_self (), *result);
-	      return ELOOP;
+	      err = ELOOP;
+	      goto out;
 	    }

 	  /* An empty RETRYNAME indicates we have the final port.  */
@@ -174,7 +177,7 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)

 	      if (err)
 		__mach_port_deallocate (__mach_task_self (), *result);
-	      return err;
+	      goto out;
 	    }

 	  startdir = *result;
@@ -189,7 +192,10 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
 	      if (*result != MACH_PORT_NULL)
 		__mach_port_deallocate (__mach_task_self (), *result);
 	      if (nloops++ >= __eloop_threshold ())
-		return ELOOP;
+		{
+		  err = ELOOP;
+		  goto out;
+		}
 	      file_name = &retryname[1];
 	      break;

@@ -208,7 +214,8 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
 		      (*end != '/' && *end != '\0'))
 		    {
 		      errno = save;
-		      return ENOENT;
+		      err = ENOENT;
+		      goto out;
 		    }
 		  if (! get_dtable_port)
 		    err = EGRATUITOUS;
@@ -226,9 +233,12 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
 		    }
 		  errno = save;
 		  if (err)
-		    return err;
+		    goto out;
 		  if (*end == '\0')
-		    return 0;
+		    {
+		      err = 0;
+		      goto out;
+		    }
 		  else
 		    {
 		      /* Do a normal retry on the remaining components.  */
@@ -255,9 +265,12 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
 		  if (err = __host_info (__mach_host_self (), HOST_BASIC_INFO,
 					 (integer_t *) &hostinfo,
 					 &hostinfocnt))
-		    return err;
+		    goto out;
 		  if (hostinfocnt != HOST_BASIC_INFO_COUNT)
-		    return EGRATUITOUS;
+		    {
+		      err = EGRATUITOUS;
+		      goto out;
+		    }
 		  p = _itoa (hostinfo.cpu_subtype, &retryname[8], 10, 0);
 		  *--p = '/';
 		  p = _itoa (hostinfo.cpu_type, &retryname[8], 10, 0);
@@ -293,10 +306,11 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
 		      }

 		  case '\0':
-		    return opentty (result);
+		    err = opentty (result);
+		    goto out;
 		  case '/':
 		    if (err = opentty (&startdir))
-		      return err;
+		      goto out;
 		    strcpy (retryname, &retryname[4]);
 		    break;
 		  default:
@@ -306,14 +320,48 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
 		goto bad_magic;
 	      break;

+	    case 'p':
+	      if (retryname[1] == 'i' && retryname[2] == 'd' &&
+		  (retryname[3] == '/' || retryname[3] == 0))
+		{
+		  char *p, buf[1024];  /* XXX */
+		  size_t len;
+		  p = _itoa (__getpid (), &buf[sizeof buf], 10, 0);
+		  len = &buf[sizeof buf] - p;
+		  memcpy (buf, p, len);
+		  strcpy (buf + len, &retryname[3]);
+		  strcpy (retryname, buf);
+
+		  /* Do a normal retry on the remaining components.  */
+		  __mach_port_mod_refs (__mach_task_self (), lastdir,
+					MACH_PORT_RIGHT_SEND, 1);
+		  startdir = lastdir;
+		  file_name = retryname;
+		}
+	      else
+		goto bad_magic;
+	      break;
+
 	    default:
 	    bad_magic:
-	      return EGRATUITOUS;
+	      err = EGRATUITOUS;
+	      goto out;
 	    }
 	  break;

 	default:
-	  return EGRATUITOUS;
+	  err = EGRATUITOUS;
+	  goto out;
+	}
+
+      if (MACH_PORT_VALID (*result) && *result != lastdir)
+	{
+	  if (MACH_PORT_VALID (lastdir))
+	    __mach_port_deallocate (__mach_task_self (), lastdir);
+
+	  lastdir = *result;
+	  __mach_port_mod_refs (__mach_task_self (), lastdir,
+				MACH_PORT_RIGHT_SEND, 1);
 	}

       if (startdir != MACH_PORT_NULL)
@@ -326,6 +374,10 @@ __hurd_file_name_lookup_retry (error_t (*use_init_port)
 	err = (*use_init_port) (dirport, &lookup_op);
     } while (! err);

+out:
+  if (MACH_PORT_VALID (lastdir))
+    __mach_port_deallocate (__mach_task_self (), lastdir);
+
   return err;
 }
 weak_alias (__hurd_file_name_lookup_retry, hurd_file_name_lookup_retry)