commit 9e8281add35dde70478464389fab6f0f7e75b880
Author: Andreas Schwab <schwab@linux-m68k.org>
Date:   Thu Feb 3 09:37:42 2022 +0100

    Regenerate configure

diff --git a/configure b/configure
index 00dc638388..8e5bee775a 100755
--- a/configure
+++ b/configure
@@ -730,7 +730,6 @@ infodir
 docdir
 oldincludedir
 includedir
-runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -845,7 +844,6 @@ datadir='${datarootdir}'
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
-runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1098,15 +1096,6 @@ do
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
-  -runstatedir | --runstatedir | --runstatedi | --runstated \
-  | --runstate | --runstat | --runsta | --runst | --runs \
-  | --run | --ru | --r)
-    ac_prev=runstatedir ;;
-  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
-  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
-  | --run=* | --ru=* | --r=*)
-    runstatedir=$ac_optarg ;;
-
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1244,7 +1233,7 @@ fi
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir runstatedir
+		libdir localedir mandir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -1397,7 +1386,6 @@ Fine tuning of the installation directories:
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
-  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]

commit d2e4d2a38e4e7bc3ca407607e717b7f50b20c63f
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Wed Feb 2 18:31:59 2022 -0300

    posix: Fix tst-spawn6 terminal handling (BZ #28853)
    
    The test changes the current foreground process group, which might
    break testing depending of how the make check is issued.  For instance:
    
      nohup make -j1 test t=posix/tst-spawn6 | less
    
    Will set 'make' and 'less' to be in the foreground process group in
    the current session.  When tst-spawn6 new child takes over it becomes
    the foreground process and 'less' is stopped and backgrounded which
    interrupts the 'make check' command.
    
    To fix it a pseudo-terminal is allocated, the test starts in new
    session (so there is no controlling terminal associated), and the
    pseudo-terminal is set as the controlling one (similar to what
    login_tty does).
    
    Checked on x86_64-linux-gnu.
    
    Tested-by: Carlos O'Donell <carlos@redhat.com>
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
    
    (cherry picked from a9d35765728cbc5b66af5eeda5428298bccf9b69)

diff --git a/NEWS b/NEWS
index faa7ec1871..b1aae94cfb 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,14 @@ See the end for copying conditions.
 
 Please send GNU C library bug reports via <https://sourceware.org/bugzilla/>
 using `glibc' in the "product" field.
+
+Version 2.35.1
+
+The following bugs are resolved with this release:
+
+  [28853] libc: tst-spawn6 changes current foreground process group
+    (breaks test isolation)
+
 
 Version 2.35
 
diff --git a/posix/tst-spawn6.c b/posix/tst-spawn6.c
index 911e90a461..044abd8535 100644
--- a/posix/tst-spawn6.c
+++ b/posix/tst-spawn6.c
@@ -29,7 +29,14 @@
 #include <support/check.h>
 #include <support/xunistd.h>
 #include <sys/wait.h>
+#include <sys/ioctl.h>
 #include <stdlib.h>
+#include <termios.h>
+
+#ifndef PATH_MAX
+# define PATH_MAX 1024
+#endif
+static char ptmxpath[PATH_MAX];
 
 static int
 handle_restart (const char *argv1, const char *argv2)
@@ -115,7 +122,7 @@ run_subprogram (int argc, char *argv[], const posix_spawnattr_t *attr,
 }
 
 static int
-do_test (int argc, char *argv[])
+run_test (int argc, char *argv[])
 {
   /* We must have either:
      - four parameters left if called initially:
@@ -127,16 +134,7 @@ do_test (int argc, char *argv[])
        + --setgrpr             optional
    */
 
-  if (restart)
-    return handle_restart (argv[1], argv[2]);
-
-  int tcfd = open64 (_PATH_TTY, O_RDONLY, 0600);
-  if (tcfd == -1)
-    {
-      if (errno == ENXIO)
-	FAIL_UNSUPPORTED ("terminal not available, skipping test");
-      FAIL_EXIT1 ("open64 (\"%s\", 0x%x, 0600): %m", _PATH_TTY, O_RDONLY);
-    }
+  int tcfd = xopen (ptmxpath, O_RDONLY, 0600);
 
   /* Check setting the controlling terminal without changing the group.  */
   {
@@ -198,5 +196,47 @@ do_test (int argc, char *argv[])
   return 0;
 }
 
+static int
+do_test (int argc, char *argv[])
+{
+  if (restart)
+    return handle_restart (argv[1], argv[2]);
+
+  pid_t pid = xfork ();
+  if (pid == 0)
+    {
+      /* Create a pseudo-terminal to avoid interfering with the one using by
+	 test itself, creates a new session (so there is no controlling
+	 terminal), and set the pseudo-terminal as the controlling one.  */
+      int ptmx = posix_openpt (0);
+      if (ptmx == -1)
+	{
+	  if (errno == ENXIO)
+	    FAIL_UNSUPPORTED ("terminal not available, skipping test");
+	  FAIL_EXIT1 ("posix_openpt (0): %m");
+	}
+      TEST_VERIFY_EXIT (grantpt (ptmx) == 0);
+      TEST_VERIFY_EXIT (unlockpt (ptmx) == 0);
+
+      TEST_VERIFY_EXIT (setsid () != -1);
+      TEST_VERIFY_EXIT (ioctl (ptmx, TIOCSCTTY, NULL) == 0);
+      while (dup2 (ptmx, STDIN_FILENO) == -1 && errno == EBUSY)
+	;
+      while (dup2 (ptmx, STDOUT_FILENO) == -1 && errno == EBUSY)
+	;
+      while (dup2 (ptmx, STDERR_FILENO) == -1 && errno == EBUSY)
+	;
+      TEST_VERIFY_EXIT (ptsname_r (ptmx, ptmxpath, sizeof ptmxpath) == 0);
+      xclose (ptmx);
+
+      run_test (argc, argv);
+      _exit (0);
+    }
+  int status;
+  xwaitpid (pid, &status, 0);
+  TEST_VERIFY (WIFEXITED (status));
+  exit (0);
+}
+
 #define TEST_FUNCTION_ARGV do_test
 #include <support/test-driver.c>

commit a2f1675634b3513c09c38e55e6766e8c05768b1f
Author: Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
Date:   Tue Feb 1 22:39:02 2022 +0000

    linux: __get_nprocs_sched: do not feed CPU_COUNT_S with garbage [BZ #28850]
    
    Pass the actual number of bytes returned by the kernel.
    
    Fixes: 33099d72e41c ("linux: Simplify get_nprocs")
    Reviewed-by: Dmitry V. Levin <ldv@altlinux.org>
    
    (cherry picked from commit 97ba273b505763325efd802dc3a9562dbba79579)

diff --git a/NEWS b/NEWS
index b1aae94cfb..d1602051d1 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ Version 2.35.1
 
 The following bugs are resolved with this release:
 
+  [28850] linux: __get_nprocs_sched reads uninitialized memory from the stack
   [28853] libc: tst-spawn6 changes current foreground process group
     (breaks test isolation)
 
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index 4798cc337e..c98c8ce3d4 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -44,7 +44,7 @@ __get_nprocs_sched (void)
   int r = INTERNAL_SYSCALL_CALL (sched_getaffinity, 0, cpu_bits_size,
 				 cpu_bits);
   if (r > 0)
-    return CPU_COUNT_S (cpu_bits_size, (cpu_set_t*) cpu_bits);
+    return CPU_COUNT_S (r, (cpu_set_t*) cpu_bits);
   else if (r == -EINVAL)
     /* The input buffer is still not enough to store the number of cpus.  This
        is an arbitrary values assuming such systems should be rare and there

commit 7001c1e38b46d5f5a90f7915b1211782341ab6a8
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Feb 3 16:52:52 2022 -0300

    linux: Fix missing __convert_scm_timestamps (BZ #28860)
    
    Commit 948ce73b31 made recvmsg/recvmmsg to always call
    __convert_scm_timestamps for 64 bit time_t symbol, so adjust it to
    always build it for __TIMESIZE != 64.
    
    It fixes build for architecture with 32 bit time_t support when
    configured with minimum kernel of 5.1.
    
    (cherry picked from 798d716df71fb23dc89d1d5dba1fc26a1b5c0024)

diff --git a/sysdeps/unix/sysv/linux/convert_scm_timestamps.c b/sysdeps/unix/sysv/linux/convert_scm_timestamps.c
index 82171bf325..dfc8c2beff 100644
--- a/sysdeps/unix/sysv/linux/convert_scm_timestamps.c
+++ b/sysdeps/unix/sysv/linux/convert_scm_timestamps.c
@@ -16,9 +16,9 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <kernel-features.h>
+#include <bits/timesize.h>
 
-#ifndef __ASSUME_TIME64_SYSCALLS
+#if __TIMESIZE != 64
 # include <stdint.h>
 # include <string.h>
 # include <sys/socket.h>

commit 24962427071fa532c3c48c918e9d64d719cc8a6c
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Feb 3 17:50:13 2022 -0300

    Add BZ#28860 reference on NEWS

diff --git a/NEWS b/NEWS
index d1602051d1..6b8db4e947 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,8 @@ The following bugs are resolved with this release:
   [28850] linux: __get_nprocs_sched reads uninitialized memory from the stack
   [28853] libc: tst-spawn6 changes current foreground process group
     (breaks test isolation)
+  [28860] build: --enable-kernel=5.1.0 build fails because of missing
+    __convert_scm_timestamps
 
 
 Version 2.35

commit 491f2ef1f0ff849490f374917957018d07ee0586
Author: Dmitry V. Levin <ldv@altlinux.org>
Date:   Sat Feb 5 08:00:00 2022 +0000

    linux: fix accuracy of get_nprocs and get_nprocs_conf [BZ #28865]
    
    get_nprocs() and get_nprocs_conf() use various methods to obtain an
    accurate number of processors.  Re-introduce __get_nprocs_sched() as
    a source of information, and fix the order in which these methods are
    used to return the most accurate information.  The primary source of
    information used in both functions remains unchanged.
    
    This also changes __get_nprocs_sched() error return value from 2 to 0,
    but all its users are already prepared to handle that.
    
    Old fallback order:
      get_nprocs:
        /sys/devices/system/cpu/online -> /proc/stat -> 2
      get_nprocs_conf:
        /sys/devices/system/cpu/ -> /proc/stat -> 2
    
    New fallback order:
      get_nprocs:
        /sys/devices/system/cpu/online -> /proc/stat -> sched_getaffinity -> 2
      get_nprocs_conf:
        /sys/devices/system/cpu/ -> /proc/stat -> sched_getaffinity -> 2
    
    Fixes: 342298278e ("linux: Revert the use of sched_getaffinity on get_nproc")
    Closes: BZ #28865
    Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
    
    (cherry picked from commit e1d32b836410767270a3adf1f82b1a47e6e4cd51)

diff --git a/NEWS b/NEWS
index 6b8db4e947..04df0f4e8a 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,8 @@ The following bugs are resolved with this release:
     (breaks test isolation)
   [28860] build: --enable-kernel=5.1.0 build fails because of missing
     __convert_scm_timestamps
+  [28865] linux: _SC_NPROCESSORS_CONF and _SC_NPROCESSORS_ONLN are inaccurate
+    without /sys and /proc
 
 
 Version 2.35
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index c98c8ce3d4..d1ea074f0d 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -50,9 +50,8 @@ __get_nprocs_sched (void)
        is an arbitrary values assuming such systems should be rare and there
        is no offline cpus.  */
     return max_num_cpus;
-  /* Some other error.  2 is conservative (not a uniprocessor system, so
-     atomics are needed). */
-  return 2;
+  /* Some other error.  */
+  return 0;
 }
 
 static char *
@@ -108,22 +107,19 @@ next_line (int fd, char *const buffer, char **cp, char **re,
 }
 
 static int
-get_nproc_stat (char *buffer, size_t buffer_size)
+get_nproc_stat (void)
 {
+  enum { buffer_size = 1024 };
+  char buffer[buffer_size];
   char *buffer_end = buffer + buffer_size;
   char *cp = buffer_end;
   char *re = buffer_end;
-
-  /* Default to an SMP system in case we cannot obtain an accurate
-     number.  */
-  int result = 2;
+  int result = 0;
 
   const int flags = O_RDONLY | O_CLOEXEC;
   int fd = __open_nocancel ("/proc/stat", flags);
   if (fd != -1)
     {
-      result = 0;
-
       char *l;
       while ((l = next_line (fd, buffer, &cp, &re, buffer_end)) != NULL)
 	/* The current format of /proc/stat has all the cpu* entries
@@ -139,8 +135,8 @@ get_nproc_stat (char *buffer, size_t buffer_size)
   return result;
 }
 
-int
-__get_nprocs (void)
+static int
+get_nprocs_cpu_online (void)
 {
   enum { buffer_size = 1024 };
   char buffer[buffer_size];
@@ -179,7 +175,8 @@ __get_nprocs (void)
 		  }
 	      }
 
-	    result += m - n + 1;
+	    if (m >= n)
+	      result += m - n + 1;
 
 	    l = endp;
 	    if (l < re && *l == ',')
@@ -188,28 +185,18 @@ __get_nprocs (void)
 	while (l < re && *l != '\n');
 
       __close_nocancel_nostatus (fd);
-
-      if (result > 0)
-	return result;
     }
 
-  return get_nproc_stat (buffer, buffer_size);
+  return result;
 }
-libc_hidden_def (__get_nprocs)
-weak_alias (__get_nprocs, get_nprocs)
-
 
-/* On some architectures it is possible to distinguish between configured
-   and active cpus.  */
-int
-__get_nprocs_conf (void)
+static int
+get_nprocs_cpu (void)
 {
-  /* Try to use the sysfs filesystem.  It has actual information about
-     online processors.  */
+  int count = 0;
   DIR *dir = __opendir ("/sys/devices/system/cpu");
   if (dir != NULL)
     {
-      int count = 0;
       struct dirent64 *d;
 
       while ((d = __readdir64 (dir)) != NULL)
@@ -224,12 +211,57 @@ __get_nprocs_conf (void)
 
       __closedir (dir);
 
-      return count;
     }
+  return count;
+}
 
-  enum { buffer_size = 1024 };
-  char buffer[buffer_size];
-  return get_nproc_stat (buffer, buffer_size);
+static int
+get_nprocs_fallback (void)
+{
+  int result;
+
+  /* Try /proc/stat first.  */
+  result = get_nproc_stat ();
+  if (result != 0)
+    return result;
+
+  /* Try sched_getaffinity.  */
+  result = __get_nprocs_sched ();
+  if (result != 0)
+    return result;
+
+  /* We failed to obtain an accurate number.  Be conservative: return
+     the smallest number meaning that this is not a uniprocessor system,
+     so atomics are needed.  */
+  return 2;
+}
+
+int
+__get_nprocs (void)
+{
+  /* Try /sys/devices/system/cpu/online first.  */
+  int result = get_nprocs_cpu_online ();
+  if (result != 0)
+    return result;
+
+  /* Fall back to /proc/stat and sched_getaffinity.  */
+  return get_nprocs_fallback ();
+}
+libc_hidden_def (__get_nprocs)
+weak_alias (__get_nprocs, get_nprocs)
+
+/* On some architectures it is possible to distinguish between configured
+   and active cpus.  */
+int
+__get_nprocs_conf (void)
+{
+  /* Try /sys/devices/system/cpu/ first.  */
+  int result = get_nprocs_cpu ();
+  if (result != 0)
+    return result;
+
+  /* Fall back to /proc/stat and sched_getaffinity.  */
+  return get_nprocs_fallback ();
 }
 libc_hidden_def (__get_nprocs_conf)
 weak_alias (__get_nprocs_conf, get_nprocs_conf)
