diff --git a/glibc-upstream-2.34-27.patch b/glibc-upstream-2.34-27.patch new file mode 100644 index 0000000..e166aa2 --- /dev/null +++ b/glibc-upstream-2.34-27.patch @@ -0,0 +1,37 @@ +commit 4bf72519987ebc2be4a2058c670379040fae90ea +Author: Florian Weimer +Date: Fri Oct 1 18:16:41 2021 +0200 + + support: Add check for TID zero in support_wait_for_thread_exit + + Some kernel versions (observed with kernel 5.14 and earlier) can list + "0" entries in /proc/self/task. This happens when a thread exits + while the task list is being constructed. Treat this entry as not + present, like the proposed kernel patch does: + + [PATCH] procfs: Do not list TID 0 in /proc//task + + + Fixes commit 032d74eaf6179100048a5bf0ce942e97dc8b9a60 ("support: Add + support_wait_for_thread_exit"). + + Reviewed-by: Carlos O'Donell + Tested-by: Carlos O'Donell + (cherry picked from commit 176c88f5214d8107d330971cbbfbbba5186a111f) + +diff --git a/support/support_wait_for_thread_exit.c b/support/support_wait_for_thread_exit.c +index 658a81381006ea62..5e3be421a78a4c78 100644 +--- a/support/support_wait_for_thread_exit.c ++++ b/support/support_wait_for_thread_exit.c +@@ -43,7 +43,10 @@ support_wait_for_thread_exit (void) + return; + } + +- if (strcmp (e->d_name, ".") == 0 || strcmp (e->d_name, "..") == 0) ++ /* In some kernels, "0" entries denote a thread that has just ++ exited. */ ++ if (strcmp (e->d_name, ".") == 0 || strcmp (e->d_name, "..") == 0 ++ || strcmp (e->d_name, "0") == 0) + continue; + + int task_tid = atoi (e->d_name); diff --git a/glibc-upstream-2.34-28.patch b/glibc-upstream-2.34-28.patch new file mode 100644 index 0000000..7becfe9 --- /dev/null +++ b/glibc-upstream-2.34-28.patch @@ -0,0 +1,154 @@ +commit 40bade26d5bcbda3d21fb598c5063d9df62de966 +Author: Florian Weimer +Date: Fri Oct 1 18:16:41 2021 +0200 + + nptl: pthread_kill must send signals to a specific thread [BZ #28407] + + The choice between the kill vs tgkill system calls is not just about + the TID reuse race, but also about whether the signal is sent to the + whole process (and any thread in it) or to a specific thread. + + This was caught by the openposix test suite: + + LTP: openposix test suite - FAIL: SIGUSR1 is member of new thread pendingset. + + + Fixes commit 526c3cf11ee9367344b6b15d669e4c3cb461a2be ("nptl: Fix race + between pthread_kill and thread exit (bug 12889)"). + + Reviewed-by: Carlos O'Donell + Tested-by: Carlos O'Donell + (cherry picked from commit eae81d70574e923ce3c59078b8df857ae192efa6) + +diff --git a/nptl/pthread_kill.c b/nptl/pthread_kill.c +index a44dc8f2d9baa925..35bf1f973eaeda90 100644 +--- a/nptl/pthread_kill.c ++++ b/nptl/pthread_kill.c +@@ -40,7 +40,7 @@ __pthread_kill_implementation (pthread_t threadid, int signo, int no_tid) + below. POSIX only guarantees delivery of a single signal, + which may not be the right one.) */ + pid_t tid = INTERNAL_SYSCALL_CALL (gettid); +- int ret = INTERNAL_SYSCALL_CALL (kill, tid, signo); ++ int ret = INTERNAL_SYSCALL_CALL (tgkill, __getpid (), tid, signo); + return INTERNAL_SYSCALL_ERROR_P (ret) ? INTERNAL_SYSCALL_ERRNO (ret) : 0; + } + +@@ -59,8 +59,6 @@ __pthread_kill_implementation (pthread_t threadid, int signo, int no_tid) + ret = no_tid; + else + { +- /* Using tgkill is a safety measure. pd->exit_lock ensures that +- the target thread cannot exit. */ + ret = INTERNAL_SYSCALL_CALL (tgkill, __getpid (), pd->tid, signo); + ret = INTERNAL_SYSCALL_ERROR_P (ret) ? INTERNAL_SYSCALL_ERRNO (ret) : 0; + } +diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile +index d4bd2d4e3ee6a496..0af9c59b425aefb1 100644 +--- a/sysdeps/pthread/Makefile ++++ b/sysdeps/pthread/Makefile +@@ -121,6 +121,7 @@ tests += tst-cnd-basic tst-mtx-trylock tst-cnd-broadcast \ + tst-pthread-setuid-loop \ + tst-pthread_cancel-exited \ + tst-pthread_cancel-select-loop \ ++ tst-pthread-raise-blocked-self \ + tst-pthread_kill-exited \ + tst-pthread_kill-exiting \ + # tests +diff --git a/sysdeps/pthread/tst-pthread-raise-blocked-self.c b/sysdeps/pthread/tst-pthread-raise-blocked-self.c +new file mode 100644 +index 0000000000000000..128e1a6071c0b15f +--- /dev/null ++++ b/sysdeps/pthread/tst-pthread-raise-blocked-self.c +@@ -0,0 +1,92 @@ ++/* Test that raise sends signal to current thread even if blocked. ++ Copyright (C) 2021 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 ++ . */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/* Used to create a dummy thread ID distinct from all other thread ++ IDs. */ ++static void * ++noop (void *ignored) ++{ ++ return NULL; ++} ++ ++static volatile pthread_t signal_thread; ++ ++static void ++signal_handler (int signo) ++{ ++ signal_thread = pthread_self (); ++} ++ ++/* Used to ensure that waiting_thread has launched and can accept ++ signals. */ ++static pthread_barrier_t barrier; ++ ++static void * ++waiting_thread (void *ignored) ++{ ++ xpthread_barrier_wait (&barrier); ++ pause (); ++ return NULL; ++} ++ ++static int ++do_test (void) ++{ ++ xsignal (SIGUSR1, signal_handler); ++ xpthread_barrier_init (&barrier, NULL, 2); ++ ++ /* Distinct thread ID value to */ ++ pthread_t dummy = xpthread_create (NULL, noop, NULL); ++ signal_thread = dummy; ++ ++ pthread_t helper = xpthread_create (NULL, waiting_thread, NULL); ++ ++ /* Make sure that the thread is running. */ ++ xpthread_barrier_wait (&barrier); ++ ++ /* Block signals on this thread. */ ++ sigset_t set; ++ sigfillset (&set); ++ xpthread_sigmask (SIG_BLOCK, &set, NULL); ++ ++ /* Send the signal to this thread. It must not be delivered. */ ++ raise (SIGUSR1); ++ TEST_VERIFY (signal_thread == dummy); ++ ++ /* Wait a bit to give a chance for signal delivery (increases ++ chances of failure with bug 28407). */ ++ usleep (50 * 1000); ++ ++ /* Unblocking should cause synchronous delivery of the signal. */ ++ xpthread_sigmask (SIG_UNBLOCK, &set, NULL); ++ TEST_VERIFY (signal_thread == pthread_self ()); ++ ++ xpthread_cancel (helper); ++ xpthread_join (helper); ++ xpthread_join (dummy); ++ return 0; ++} ++ ++#include diff --git a/glibc-rh1992702-1.patch b/glibc-upstream-2.34-29.patch similarity index 85% rename from glibc-rh1992702-1.patch rename to glibc-upstream-2.34-29.patch index 528156a..2a35ad6 100644 --- a/glibc-rh1992702-1.patch +++ b/glibc-upstream-2.34-29.patch @@ -1,9 +1,6 @@ -Patch proposed for upstream inclusion: - - - +commit e870aac8974cda746157a5a3c9f452ccd70da29b Author: Adhemerval Zanella -Date: Tue Sep 7 09:22:57 2021 -0300 +Date: Mon Sep 6 12:22:54 2021 -0300 misc: Add __get_nprocs_sched @@ -13,7 +10,9 @@ Date: Tue Sep 7 09:22:57 2021 -0300 The Linux implementation currently only calls __get_nprocs(), which in tuns calls sched_getaffinity. + Reviewed-by: Florian Weimer + (cherry picked from commit 11a02b035b464ab6813676adfd19c4a59c36d907) diff --git a/include/sys/sysinfo.h b/include/sys/sysinfo.h index 7388356a19269335..c490561581733038 100644 @@ -37,10 +36,10 @@ index 7388356a19269335..c490561581733038 100644 extern long int __get_phys_pages (void); libc_hidden_proto (__get_phys_pages) diff --git a/malloc/arena.c b/malloc/arena.c -index 4c398753aeadbb9d..78ef4cf18c780dfc 100644 +index 667484630ed0afa5..f1f0af86489d0063 100644 --- a/malloc/arena.c +++ b/malloc/arena.c -@@ -878,7 +878,7 @@ arena_get2 (size_t size, mstate avoid_arena) +@@ -879,7 +879,7 @@ arena_get2 (size_t size, mstate avoid_arena) narenas_limit = mp_.arena_max; else if (narenas > mp_.arena_test) { @@ -50,10 +49,10 @@ index 4c398753aeadbb9d..78ef4cf18c780dfc 100644 if (n >= 1) narenas_limit = NARENAS_FROM_NCORES (n); diff --git a/misc/getsysstats.c b/misc/getsysstats.c -index 2986d62247cf98ca..5cbba0f9bd93bd78 100644 +index 0eedface6d2b0f75..57d93601e21265d7 100644 --- a/misc/getsysstats.c +++ b/misc/getsysstats.c -@@ -44,6 +44,12 @@ weak_alias (__get_nprocs, get_nprocs) +@@ -45,6 +45,12 @@ weak_alias (__get_nprocs, get_nprocs) link_warning (get_nprocs, "warning: get_nprocs will always return 1") @@ -84,10 +83,10 @@ index 1267f39da26aee38..cc8023f979bf6f74 100644 long int __get_phys_pages (void) diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c -index 8a5d342f0c8bbeae..e9c0dc4d83d4fb2a 100644 +index 1391e360b8f8e86c..120ce1bb756b09cc 100644 --- a/sysdeps/unix/sysv/linux/getsysstats.c +++ b/sysdeps/unix/sysv/linux/getsysstats.c -@@ -87,6 +87,12 @@ __get_nprocs (void) +@@ -88,6 +88,12 @@ __get_nprocs (void) libc_hidden_def (__get_nprocs) weak_alias (__get_nprocs, get_nprocs) diff --git a/glibc-rh1992702-2.patch b/glibc-upstream-2.34-30.patch similarity index 93% rename from glibc-rh1992702-2.patch rename to glibc-upstream-2.34-30.patch index 40fe556..7255a98 100644 --- a/glibc-rh1992702-2.patch +++ b/glibc-upstream-2.34-30.patch @@ -1,9 +1,6 @@ -Patch proposed for upstream inclusion: - - - +commit cda99af14e82b4bb6abaecd717ebe3b57c0aa534 Author: Adhemerval Zanella -Date: Tue Sep 7 09:22:58 2021 -0300 +Date: Mon Sep 6 12:28:24 2021 -0300 linux: Simplify get_nprocs @@ -53,7 +50,9 @@ Date: Tue Sep 7 09:22:58 2021 -0300 with large buffers. Checked on x86_64-linux-gnu and i686-linux-gnu. + Reviewed-by: Florian Weimer + (cherry picked from commit 33099d72e41cf8a129b362e9709eb2be9372d844) diff --git a/posix/Makefile b/posix/Makefile index a5229777eeb0e067..61fcdf015b4ec83b 100644 @@ -71,10 +70,10 @@ index a5229777eeb0e067..61fcdf015b4ec83b 100644 ifeq ($(have-GLIBC_2.26)$(build-shared),yesyes) diff --git a/posix/tst-sched_getaffinity.c b/posix/tst-sched_getaffinity.c new file mode 100644 -index 0000000000000000..6d1fdcb05ff4d16c +index 0000000000000000..db9d517a96fdd99e --- /dev/null +++ b/posix/tst-sched_getaffinity.c -@@ -0,0 +1,47 @@ +@@ -0,0 +1,48 @@ +/* Tests for sched_getaffinity with large buffers. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. @@ -91,18 +90,20 @@ index 0000000000000000..6d1fdcb05ff4d16c + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see -+ . */ ++ . */ + +#include +#include +#include + ++/* NB: this test may fail on system with more than 32k cpus. */ ++ +static int +do_test (void) +{ + /* The values are larger than the default cpu_set_t. */ + const int bufsize[] = { 1<<11, 1<<12, 1<<13, 1<<14, 1<<15, 1<<16, 1<<17 }; -+ int cpucount[array_length(bufsize)]; ++ int cpucount[array_length (bufsize)]; + + for (int i = 0; i < array_length (bufsize); i++) + { @@ -115,18 +116,17 @@ index 0000000000000000..6d1fdcb05ff4d16c + } + + for (int i = 0; i < array_length (cpucount) - 1; i++) -+ for (int j = 1; j < array_length (cpucount); j++) -+ TEST_COMPARE (cpucount[i], cpucount[j]); ++ TEST_COMPARE (cpucount[i], cpucount[i + 1]); + + return 0; +} + +#include diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c -index e9c0dc4d83d4fb2a..1e3d88676df37f81 100644 +index 120ce1bb756b09cc..61d20e7bab8640f2 100644 --- a/sysdeps/unix/sysv/linux/getsysstats.c +++ b/sysdeps/unix/sysv/linux/getsysstats.c -@@ -28,61 +28,29 @@ +@@ -29,61 +29,29 @@ #include #include diff --git a/glibc-rh1992702-3.patch b/glibc-upstream-2.34-31.patch similarity index 94% rename from glibc-rh1992702-3.patch rename to glibc-upstream-2.34-31.patch index e944874..cb04843 100644 --- a/glibc-rh1992702-3.patch +++ b/glibc-upstream-2.34-31.patch @@ -1,9 +1,6 @@ -Patch proposed for upstream inclusion: - - - +commit 822662cf2a4b170ade4c5342f035d68815a03276 Author: Adhemerval Zanella -Date: Tue Sep 7 09:22:59 2021 -0300 +Date: Mon Sep 6 14:19:51 2021 -0300 linux: Revert the use of sched_getaffinity on get_nproc (BZ #28310) @@ -30,13 +27,15 @@ Date: Tue Sep 7 09:22:59 2021 -0300 So the implementation first consult the sysfs, and fallbacks to procfs. Checked on x86_64-linux-gnu. + Reviewed-by: Florian Weimer + (cherry picked from commit 342298278eabc75baabcaced110a11a02c3d3580) diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c -index 1e3d88676df37f81..15ad91cf2f5905ac 100644 +index 61d20e7bab8640f2..d70ed9586950615c 100644 --- a/sysdeps/unix/sysv/linux/getsysstats.c +++ b/sysdeps/unix/sysv/linux/getsysstats.c -@@ -17,6 +17,8 @@ +@@ -18,6 +18,8 @@ . */ #include @@ -45,7 +44,7 @@ index 1e3d88676df37f81..15ad91cf2f5905ac 100644 #include #include #include -@@ -29,7 +31,7 @@ +@@ -30,7 +32,7 @@ #include int @@ -54,7 +53,7 @@ index 1e3d88676df37f81..15ad91cf2f5905ac 100644 { enum { -@@ -52,14 +54,141 @@ __get_nprocs (void) +@@ -53,14 +55,141 @@ __get_nprocs (void) atomics are needed). */ return 2; } diff --git a/glibc-upstream-2.34-32.patch b/glibc-upstream-2.34-32.patch new file mode 100644 index 0000000..d5fddc0 --- /dev/null +++ b/glibc-upstream-2.34-32.patch @@ -0,0 +1,42 @@ +commit 80a009119ba2330768120476aaad63767b81d543 +Author: Jonathan Wakely +Date: Wed May 19 16:48:19 2021 +0100 + + Suppress -Wcast-qual warnings in bsearch + + The first cast to (void *) is redundant but should be (const void *) + anyway, because that's the type of the lvalue being assigned to. + + The second cast is necessary and intentionally not const-correct, so + tell the compiler not to warn about it. + + Reviewed-by: Florian Weimer + (cherry picked from commit a725ff1de965f4cc4f36a7e8ae795d40ca0350d7) + +diff --git a/bits/stdlib-bsearch.h b/bits/stdlib-bsearch.h +index 4132dc6af0077f31..d688ed2e15678e9c 100644 +--- a/bits/stdlib-bsearch.h ++++ b/bits/stdlib-bsearch.h +@@ -29,14 +29,21 @@ bsearch (const void *__key, const void *__base, size_t __nmemb, size_t __size, + while (__l < __u) + { + __idx = (__l + __u) / 2; +- __p = (void *) (((const char *) __base) + (__idx * __size)); ++ __p = (const void *) (((const char *) __base) + (__idx * __size)); + __comparison = (*__compar) (__key, __p); + if (__comparison < 0) + __u = __idx; + else if (__comparison > 0) + __l = __idx + 1; + else ++#if __GNUC_PREREQ(4, 6) ++# pragma GCC diagnostic push ++# pragma GCC diagnostic ignored "-Wcast-qual" ++#endif + return (void *) __p; ++#if __GNUC_PREREQ(4, 6) ++# pragma GCC diagnostic pop ++#endif + } + + return NULL; diff --git a/glibc-upstream-2.34-33.patch b/glibc-upstream-2.34-33.patch new file mode 100644 index 0000000..f7f9ca9 --- /dev/null +++ b/glibc-upstream-2.34-33.patch @@ -0,0 +1,37 @@ +commit a996d13b8a2e101bedbb1bdaa7ffcfea3b959bb2 +Author: Florian Weimer +Date: Thu Sep 30 18:44:06 2021 +0200 + + Add missing braces to bsearch inline implementation [BZ #28400] + + GCC treats the pragma as a statement, so that the else branch only + consists of the pragma, not the return statement. + + Fixes commit a725ff1de965f4cc4f36a7e8ae795d40ca0350d7 ("Suppress + -Wcast-qual warnings in bsearch"). + + Reviewed-by: H.J. Lu + (cherry picked from commit 32b96d0dec0294465d2221a8f049703599d9d8e4) + +diff --git a/bits/stdlib-bsearch.h b/bits/stdlib-bsearch.h +index d688ed2e15678e9c..e2fcea6e172af72c 100644 +--- a/bits/stdlib-bsearch.h ++++ b/bits/stdlib-bsearch.h +@@ -36,14 +36,16 @@ bsearch (const void *__key, const void *__base, size_t __nmemb, size_t __size, + else if (__comparison > 0) + __l = __idx + 1; + else ++ { + #if __GNUC_PREREQ(4, 6) + # pragma GCC diagnostic push + # pragma GCC diagnostic ignored "-Wcast-qual" + #endif +- return (void *) __p; ++ return (void *) __p; + #if __GNUC_PREREQ(4, 6) + # pragma GCC diagnostic pop + #endif ++ } + } + + return NULL; diff --git a/glibc.spec b/glibc.spec index 9937dd8..ca9a03a 100644 --- a/glibc.spec +++ b/glibc.spec @@ -151,7 +151,7 @@ end \ Summary: The GNU libc libraries Name: glibc Version: %{glibcversion} -Release: 6%{?dist} +Release: 7%{?dist} # In general, GPLv2+ is used by programs, LGPLv2+ is used for # libraries. @@ -257,9 +257,13 @@ Patch54: glibc-upstream-2.34-23.patch Patch55: glibc-upstream-2.34-24.patch Patch56: glibc-upstream-2.34-25.patch Patch57: glibc-upstream-2.34-26.patch -Patch1001: glibc-rh1992702-1.patch -Patch1002: glibc-rh1992702-2.patch -Patch1003: glibc-rh1992702-3.patch +Patch58: glibc-upstream-2.34-27.patch +Patch59: glibc-upstream-2.34-28.patch +Patch60: glibc-upstream-2.34-29.patch +Patch61: glibc-upstream-2.34-30.patch +Patch62: glibc-upstream-2.34-31.patch +Patch63: glibc-upstream-2.34-32.patch +Patch64: glibc-upstream-2.34-33.patch ############################################################################## # Continued list of core "glibc" package information: @@ -2291,6 +2295,18 @@ fi %files -f compat-libpthread-nonshared.filelist -n compat-libpthread-nonshared %changelog +* Fri Oct 1 2021 Florian Weimer - 2.34-7 +- Drop glibc-rh1992702-*.patch, applied upstream. (#1992702) +- Sync with upstream branch release/2.34/master, + commit a996d13b8a2e101bedbb1bdaa7ffcfea3b959bb2: +- Add missing braces to bsearch inline implementation [BZ #28400] +- Suppress -Wcast-qual warnings in bsearch +- linux: Revert the use of sched_getaffinity on get_nproc (BZ #28310) +- linux: Simplify get_nprocs +- misc: Add __get_nprocs_sched +- nptl: pthread_kill must send signals to a specific thread [BZ #28407] +- support: Add check for TID zero in support_wait_for_thread_exit + * Thu Sep 23 2021 Florian Weimer - 2.34-6 - Sync with upstream branch release/2.34/master, commit 33adeaa3e2b9143c38884bc5aa65ded222ed274e: